Skip to content

Instantly share code, notes, and snippets.

@jappy
Created March 11, 2012 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jappy/2015427 to your computer and use it in GitHub Desktop.
Save jappy/2015427 to your computer and use it in GitHub Desktop.
unix command to count sequences of consonants in a text
tr 'a-z' 'A-Z' < filename.txt | tr -sc 'BCDFGHJKLMNPQRSTVWXYZ' '\n' | sort | uniq -c | sort -nr
@shobbo
Copy link

shobbo commented Mar 11, 2012

why not just tr -cd '’BCDFGHJKLMNPQRSTVWXYZ' | uniq -c | sort -nr

@jappy
Copy link
Author

jappy commented Mar 12, 2012

I am not able to get your command to behave similarly. Can you give me an example? Perhaps I am trying it incorrectly.

You should get an output like this, depending on the text:

6029 TH
4972 S
4227 ND
3939 R
3912 N
3843 H
3603 D
3360 T
3273 M
2922 F
2164 W
1778 B
1666 L
1516 C
1265 Y
1164 V
1124 NT
1045 LL
967 G
790 SH

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