User Tools

Site Tools


awk_examples

If you want to send us your comments, please do so. Thanks
More on comments


AWK Examples

for

Probably work with GNU Awk 4.1.4, API: 1.1 (GNU MPFR 3.1.5, GNU MP 6.1.2)

awk 'BEGIN { print sqrt(18/3) }'
echo "0.4 0.7" | awk '{printf "%2.2f\n", $1 * $2}'

Find linenumber

awk '/string/{ print NR; exit }' file.txt
awk 'match($0,v){print NR; exit}' v=string file.txt # With a variable

Replace characters
Built-in Variables: FS, OFS, RS, ORS, NF, NR, FNR, FILENAME

awk '{print $3,$2,$1}' RS="\n\n" FS="\n" OFS=";" somefile.txt

Main subjects on this wiki: Linux, Debian, HTML, Microcontrollers, Privacy

RSS
Disclaimer
Privacy statement
Bugs statement
Cookies
Copyright © : 2014 - 2024 Webevaluation.nl and the authors
Changes reserved.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
awk_examples.txt · Last modified: 08-03-2022 22:25 by wim