awk
Pattern scanning and processing language. Perfect for column extraction, aggregation, and quick reports.
Synopsis
awk [options] 'pattern { action }' file
Core Options
-F, --field-separatorSet field separator (e.g., -F',' for CSV).
-v var=valuePass variables into the awk program.
-f fileRead awk program from a file.
Usage Examples
Print Columns
Print first and third columns from a space-delimited file.
awk '{print $1, $3}' data.txtCSV Column
Extract the email column from a CSV file.
awk -F',' '{print $3}' users.csvFilter Rows
Show lines where the 5th column is greater than 100.
awk '$5 > 100 {print $0}' report.txtAggregate Sum
Sum the 2nd column.
awk '{sum += $2} END {print sum}' numbers.txtAdd Headers
Add a header row and format output.
awk 'BEGIN {print "name\tcount"} {print $1 "\t" $2}' stats.txtBuilt for builders.