Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been doing | sort | uniq -c | sort -n for years! Just wondering if somewhere buried in the command stack that people have been updating for years if there is a simple alternative.

share|improve this question
What do you want to achive? Any kind of improvement or just type less? – ghm1014 Mar 14 '12 at 18:11
up vote 2 down vote accepted

Maybe name it quniqsort? Mindset of Unix: keeping it simple and chaining small things together.

sort < /dev/stdin | uniq -c | sort -n
share|improve this answer
I would probably change this to -- sort $* | uniq -c | sort -n since then the script can take optional arguments. – koblas Mar 14 '12 at 18:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.