Skip to main content

CLI Tricks: Finding interesting words

Most Linux, BSD, MacOS machines come with /usr/share/dict/words so a little awk, grep, and other shell utilities can find some interesting words.

The longest words consisting of only vowels
awk '
  !/^[aeiou]*$/ {next}
  length == m {a[++i]=$0}
  length > m {delete a; a[i=0]=$0; m=length}
  END {for (i in a) print a[i]}
  ' /usr/share/dict/words
The longest words you can type with the left hand
awk '
  !/^[qwertasdfgzxcvb]*$/ {next}
  length == m {a[++i]=$0}
  length > m {delete a; a[i=0]=$0; m=length}
  END {for (i in a) print a[i]}
  ' /usr/share/dict/words
The longest words you can type with the right hand
awk '
  !/^[yuiophjklnm]*$/ {next}
  length == m {a[++i]=$0}
  length > m {delete a; a[i=0]=$0; m=length}
  END {for (i in a) print a[i]}
  ' /usr/share/dict/words
Words you can make out of SNICKERS singles
Around Halloween, the kids often get these Snickers singles with one letter per disappointing chocolate. What words can we spell with them?
grep '^[snickers]*$' /usr/share/dict/words
The longest words you can type alternating hands
awk '
  !(/^[qwertasdfgzxcvb]([yuiophjklnm][qwertasdfgzxcvb])*$/ || /^[yuiophjklnm]([qwertasdfgzxcvb][yuiophjklnm])*$/) {next}
  length == m {a[++i]=$0}
  length > m {delete a; a[i=0]=$0; m=length}
  END {for (i in a) print a[i]}
  ' /usr/share/dict/words
Words containing the same letter 3 times consecutively
grep '\(.\)\1\1' /usr/share/dict/words