Skip to Content
Navigation:

A stick figure smiling

Here's a preview from my zine, Bite Size Command Line!! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!

Image of a comic. To read the full HTML alt text, click "read the transcript". browse more comics! get the zine!
read the transcript!

sort sorts its inputs

$ sort name.txt

the default sort is alphabetical

sort -n: numeric sort

sort order (sad face):

  • 12
  • 15000
  • 48
  • 6020
  • 96

sort -n order (happy face):

  • 12
  • 48
  • 96
  • 6020
  • 15000

sort -h: human sort

sort -n order (sad face):

  • 15 G
  • 30 M
  • 45 K
  • 200 G

sort -h order (happy face):

  • 45 K
  • 30 M
  • 15 G
  • 200 G

useful example: du -sh * | sort -h

uniq removes duplicates

before:

  • a
  • b
  • b
  • a
  • c
  • c

after:

  • a
  • b
  • a
  • c

(notice there are still 2 ‘a’s! uniq only uniquifies adjacent matching lines

sort + uniq = (heart)

Pipe something to sort | uniq and you’ll get a deduplicated list of lines! sort -u does the same thing.

before sort -u (or sort | uniq):

  • b
  • a
  • b
  • a

after:

  • a
  • b

uniq -c

counts each line it saw.

Recipe: get the top 10 most common lines in a file:

$ sort foo.txt
   | uniq -c
   | sort -n
   | tail -n 10

happy little stick figure with curly hair: I use this a lot!

Saturday Morning Comics!

Want another comic like this in your email every Saturday? Sign up here!

I'll send you one of my favourite comics from my archives every Saturday.
© Julia Evans 2025 | All rights reserved (see the FAQ for notes about licensing)