Reformat output
Aligned printf formatting with fixed column widths
awk '{printf "%-20s %5d\n", $1, $2}' data.txt
- tool
- awk15 commands
More awk commands
-
awk -f transform.awk input.txtLoad awk program from an external script file
-
awk '{gsub(/foo/, "bar"); print}' input.txt > tmp && mv tmp input.txtGlobal substitution and write back to same file
-
gawk -v FPAT='([^,]+)|("[^"]+")' '{print $2}' data.csvParse quoted CSV fields correctly with FPAT in gawk
-
awk 'BEGIN{print "Start"} {lines++} END{print lines" lines processed"}' file.txtRun code before and after processing all lines
-
awk 'NR==FNR{a[$1]=$2; next} $1 in a {print $0, a[$1]}' lookup.txt data.txtLeft-join data.txt with lookup.txt on first field