Skip to content

Instantly share code, notes, and snippets.

@ngsw
Created August 28, 2011 04:14
Show Gist options
  • Save ngsw/1176234 to your computer and use it in GitHub Desktop.
Save ngsw/1176234 to your computer and use it in GitHub Desktop.
bash Frequency count
command | sort | uniq -c | sort -nr
@ngsw
Copy link
Author

ngsw commented Aug 28, 2011

$ cat testfile
a 1 2
a 2 3
d 0 3
a 3 4
a 5 6
b 1 2
b 2 3
c 2 2
m 9 3

$ cut -d' ' -f 1 testfile |sort |uniq -c |sort -nr
4 a
2 b
1 m
1 d
1 c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment