Tsallaka zuwa abun ciki
Justice Tech School

sort, uniq, cut, tr, wc

sort orders lines, uniq collapses neighbours, cut selects columns, tr translates characters, wc counts lines, words and bytes, head and tail show the ends.

Example
printf "b 2\na 1\nb 2\nc 3\n" | sort | uniq
printf "b 2\na 1\nb 2\n" | sort | uniq -c
echo "a:b:c" | cut -d: -f2,3
echo "hello" | tr a-y b-z
seq 10 | head -3 | tail -1
printf "one two\nthree\n" | wc -lw

Result

a 1
b 2
c 3
      1 a 1
      2 b 2
b:c
ifmmp
3
      2       3

Exercise

Reverse sort numerically.

sort -

Quiz Test

Why sort before uniq?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.