Skip to content

Instantly share code, notes, and snippets.

@christophchamp
Last active February 26, 2020 10:02
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 christophchamp/07c58176b03ddf0c28b931dccc636181 to your computer and use it in GitHub Desktop.
Save christophchamp/07c58176b03ddf0c28b931dccc636181 to your computer and use it in GitHub Desktop.

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