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.
Asked
Active
Viewed 788 times
2
koblas
- 155
-
What do you want to achive? Any kind of improvement or just type less? – ghm1014 Mar 14 '12 at 18:11
1 Answers
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 thansort $*(at least in bash). – musiphil Mar 07 '22 at 23:34