0

awk stuff

print all lines in a file that match some pattern awk ‘$0 ~ /pattern/ {print $0}’ awk ‘NR % 6’ # prints all lines except those divisible by 6 awk ‘NR > 5’ # prints from line 6 onwards (like tail -n +6, or sed ‘1,5d’) awk ‘$2 == “foo”‘ # prints lines where the second field is “foo” awk ‘NF >= 6’ # prints lines with 6 or more fields awk ‘/foo/ && /bar/’ # prints lines that match /foo/ and /bar/, in any order awk ‘/foo/ && !/bar/’ # prints lines that match /foo/ but not /bar/ awk… Continue Reading