Awk is a very powerful utility, but its syntax is less than intuitive to a beginner. Here are a few common but very powerful things you can do with awk:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# print line 2 of the file awk 'NR == 2' myFile.txt # print column 2 of the file awk '{print $2}' myFile.txt # add up column 2 awk '{s += $4} END {print s}' # print all the lines with more than 80 columns awk 'length($0) > 80' myFile.txt # print the number of lines in the file awk 'END { print NR }' myFile.txt # count the number of lines where column 2 is greater than column 1 awk '$2 > $1 {print i + "1"; i++}' myFile.txt |




