Tools
AWK Cheat Sheet
Print-ready cheat sheet for AWK, organized for fast lookup, study, and desk-side use
Sample
What's in this cheat sheet
- Basics
- Patterns & Actions
- Variables
- Fields
- Control Flow
- Functions
- Arrays
- String Functions
- I/O
- Common Patterns
Running AWK
awk '{ print }' file.txt # print every line
awk '{ print $1 }' file.txt # print first field
awk -F: '{ print $1 }' /etc/passwd # custom delimiter
awk -f script.awk file.txt # run from file
cmd | awk '{ print $2 }' # pipe input
Program Structure
awk 'pattern { action }' | Basic form — action runs when pattern matches |
BEGIN { ... } | Runs once before processing input |
END { ... } | Runs once after all input is processed |
No pattern | Action runs for every line |
No action | Default action is `{ print }` |
Download the full cheat sheet for all sections, formatted for print
Download PDFDownloads
Choose the treatment that matches how you read
-
Recommended
Standard
B&W, ink-efficient. The default for laser printers and photocopies
Best for Printouts and desk-side reference
-
Color
Warm color accents for on-screen reading or color printers
Best for Screen reading or color printers
-
Reference Card
Maximum density, 4-column layout. Everything on one page
Best for Fast scanning and minimum paper use