awk
CLIPattern-scanning and text-processing language.
Column-based text processing and pattern matching
Recipes
Curated from documentation and usage. Percentages are estimates, not measurements.
Print specific column from output
ps aux | awk '{print $2}'Sum a column of numbers
awk '{sum+=$1} END {print sum}' file.txtFilter rows by condition
awk '$3 > 100' data.txtParse CSV and print column
awk -F',' '{print $2}' data.csvCommon failures (1)
- a field is quoted because it contains a comma — columns shift from that field onward, silently, exit 0awk -F',' is not a CSV parser; use csvcut -c 2 data.csv (pip install csvkit) or mlr --csv --implicit-csv-header --headerless-csv-output cut -f 2 data.csv
Fallback
csvcut -c 2 data.csvInstall
apt
sudo apt install gawkAgent notes
- When to use
- Extracting columns, computing sums, reformatting tabular text
- Quick examples
awk '{print $1}' file.txtawk -F',' '{sum+=$2} END {print sum}' data.csv
Use from an agent
curl -s https://clihub.com/api/tools/awk | jq '.agentHints.provenRecipes[] | {task, command, verified}'Or call get_tool with slug awk on the MCP server at https://clihub.com/mcp.