2

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.

koblas
  • 155

1 Answers1

2

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

#/bin/sh
sort < /dev/stdin | uniq -c | sort -n
Jeff Ferland
  • 20,687
  • 2
  • 63
  • 85
  • 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
  • @koblas -- I've started using alias sus='sort | uniq -c | sort -n' which you can remember easily given Among Us :) – c4urself May 07 '21 at 19:03
  • sort "$@" preserves the word boundaries and thus is better than sort $* (at least in bash). – musiphil Mar 07 '22 at 23:34