Skip to content

Instantly share code, notes, and snippets.

@andrewgho
Created October 27, 2022 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andrewgho/bd6ec8f32ebcdad59860ce524a94b515 to your computer and use it in GitHub Desktop.
Save andrewgho/bd6ec8f32ebcdad59860ce524a94b515 to your computer and use it in GitHub Desktop.
#!/bin/sh
# bee - return Spelling Bee words from maximal set
# Andrew Ho <andrew@zeuscat.com>
ME=`basename "$0"`
USAGE="usage: $ME letters middle-letter"
die_usage() { (echo "$ME: $@"; echo "$USAGE") 1>&2; exit 1; }
letters="$1"
[[ -z "$letters" ]] && die_usage 'missing required letters'
middle="$2"
[[ -z "$middle" ]] && die_usage 'missing required middle letter'
pcregrep -hi "^[$letters]{4,}$" \
~/work/wordchomp/ospd3.txt \
/usr/share/dict/words |
fgrep -i "$middle" |
sort -fu |
awk '{ print length, $0 }' |
sort -n |
cut -d' ' -f2-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment