sort, uniq, cut, wc, tr — text stream processing
cheat sheet · GNU coreutils https://lab.dimsanych.ru/en/wiki/text-tools/Cheat sheet
-
sort -u filesort + unique -
sort file | uniq -c | sort -rnline frequency (top) -
cut -d: -f1 filea column by delimiter -
tr 'a-z' 'A-Z' < filecase conversion -
column -t -s, file.csvalign into a table -
comm -12 <(sort a) <(sort b)the intersection of two files
Options
sort without -n compares lines as text: 10 sorts before 9,
because the character "1" is less than "9" — numeric order needs -n.
uniq only collapses lines that are identical and adjacent, so it almost
always needs a sort first. cut splits fields on a tab by default —
for CSV or passwd you set the delimiter explicitly with -d.