Filter rows by pattern awk
Print line number and content for lines matching ERROR
awk '/ERROR/ {print NR": "$0}' app.log
more awk
all 15 commands →
Sum a column
awk '{sum += $4} END {print sum}' access.log
Print lines between two patterns
awk '/START/,/END/' file.txt
Skip header line
awk 'NR>1 {print $1, $2}' data.csv
Count occurrences per key
awk '{count[$1]++} END {for (k in count) print count[k], k}' access.log | sort -rn
Print last field
awk '{print $NF}' file.txt