Skip to content

Instantly share code, notes, and snippets.

@roblogic
Last active October 12, 2020 05:20
Show Gist options
  • Select an option

  • Save roblogic/058f477de81964c9562697a9730d096f to your computer and use it in GitHub Desktop.

Select an option

Save roblogic/058f477de81964c9562697a9730d096f to your computer and use it in GitHub Desktop.
#!/bin/sh
#set -x
info="Usage: anag <5-letter-word>
find 3-5 letter anagrams of a 5 letter word"
[ $1 ] || { echo "$info";exit; }
main(){
for i in 3 4 5; do
grep -h -E ^[$1]{$i}$ * \
| sort -u \
| grep -v -E "(.)(.*\1)"
done
}
main $1 | paste - - - - -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment