category 01 / 10
Text processing
Sorting, filtering, reformatting, and slicing text from the terminal.
005
entries
3 min
avg read
047Skip the header line of a file before you sort or count ittail -n +2 sales.csv035Pull only the matching records out of a JSON filejq -r '.servers[] | select(.cpu > 60) | [.name, .ip, .cpu] | @tsv' data.json030Line up a CSV into readable columns right in the terminalcolumn -s, -t sales.csv022Total a column grouped by another one in a single passawk '{n[$7]++; bytes[$7]+=$10} END {for (u in n) printf "%12.0f %6d %s\n", bytes[u], n[u], u}' access.log | sort -rn | head007Sort a CSV by any column without opening a spreadsheetsort -t, -k3 -nr sales.csv | head -20
showing 005 of 005