Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Find lowercase letter frequencies in English words

  • Issues with the following Linux/Bash one-liner:
    • It is ugly
    • It has trailing tabs (\t)
  • Challenge:
    • Come up with a more elegant and concise Linux one-liner.
  • Rules:
    • You must only use Linux and/or Bash and it must be able to be run from the Linux CLI as a one-liner.
$ for i in $(echo {a..z}); do (echo ${i}; grep -E "^${i}.*" /usr/share/dict/words|wc -l) | tr '\n' '\t'; echo -e "\n"; done | sort -nk2 | sed '/^$/d'
x	17	
z	146	
y	282	
q	413	
k	605	
j	775	
v	1268	
n	1536	
u	1823	
o	1955	
w	2329	
l	2614	
g	2767	
h	3097	
e	3296	
i	3362	
f	3701	
t	4332	
m	4446	
a	4676	
r	4703	
b	4882	
d	5137	
p	6797	
c	8199	
s	10019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment