Practical text reshaping and data extraction at the shell prompt using awk. 16.11.2025 | reading time: 2 min Awk is a small programming language built for text: split lines into fields, apply patterns, and print new formats; this lesson shows how to do it and why you will reach for awk when other tools fail. Reformat CSV to TSV Try this: ```bash $ cat servers.csv id,name,ip,status 1,web01,10.0.0.1,active 2,db01,10.0.0.2,offline $ awk -F, -v OFS="\t" 'NR>1{print $2, $3}' servers.csv web01 10.0.0.1 db01 10.0.0.2 ``` This reads a comma file, skips the header, and prints name and IP as a tab-separated list you can redirect into a new file. Calculate and filter Aggregate and conditionally emit results: `awk -F, 'NR>1 && $4>100 {sum+=$4} END{print sum}' sales.csv` sums a numeric fourth column only when it exceeds 100; use `BEGIN` and `END` blocks, `FS`/`OFS`, associative arrays and `printf` for precise formatting. Work with patterns and formats Match with regular expressions, rearrange columns, derive new fields, or call external commands via `system()`; awk handles records (`RS`) and fields (`FS`) and scales from one-liners to small scripts when you need readable, fast text transforms. Complementary tools Use `sed` for stream edits, `cut` for simple column extraction, and `csvkit` or `jq` when you need CSV-aware or JSON-aware processing; combine tools in pipelines to get the job done without overcomplicating a single command. Where to go next Master a few awk idioms and you will edit logs, reshape exports, and prototype parsers in minutes; if you want deeper Linux skills consider exam-focused training and certifications like CompTIA Linux+ or LPIC-1 and intensive preparation at bitsandbytes.academy to turn practice into proof. Join Bits & Bytes Academy First class LINUX exam preparation. utilities scripting troubleshooting