In-place-style transform with awk awk
Global substitution and write back to same file
awk '{gsub(/foo/, "bar"); print}' input.txt > tmp && mv tmp input.txt
more awk
all 15 commands →
Process CSV with quotes (gawk)
gawk -v FPAT='([^,]+)|("[^"]+")' '{print $2}' data.csv
BEGIN/END blocks
awk 'BEGIN{print "Start"} {lines++} END{print lines" lines processed"}' file.txt
Two-file join on key
awk 'NR==FNR{a[$1]=$2; next} $1 in a {print $0, a[$1]}' lookup.txt data.txt
Print specific column
awk '{print $3}' file.txt
Custom field separator
awk -F: '{print $1, $3}' /etc/passwd