summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2017-01-26 01:27:42 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2017-01-26 01:28:10 -0500
commit70c0690e56f8906296513c10a3cd4c37e63f742d (patch)
tree93f1b08b435d7bfe7ecda8fc2a4cb1650e8e37a8
parent6c22a135015a9e5f54050d5c73bbde0daee3538a (diff)
hangman-helper: improve
-rw-r--r--hangman-helper.sh6
1 files changed, 3 insertions, 3 deletions
diff --git a/hangman-helper.sh b/hangman-helper.sh
index 3ed1c17..c46bb1e 100644
--- a/hangman-helper.sh
+++ b/hangman-helper.sh
@@ -7,7 +7,7 @@
#
# Without the `-l` flag, it produces a list of possible completions.
#
-# With the `-l` flag, it produces a list of letters,
+# With the `-l` flag, it produces a list of letters not in <word>,
# sorted by the number of times they appear in the normal list
word=$1
@@ -16,8 +16,8 @@ flag=$3
grep -ix "$word" /usr/share/dict/words | grep -iv "['$not]" | {
if [[ "$flag" = '-l' ]]; then
- tr 'A-Z' 'a-z' | sed 's/\(.\)/\1\n/'g | sort | uniq -c | sort -n
+ tr 'A-Z' 'a-z' | sed 's/\(.\)/\1\n/'g | grep -v -e "[$word]" -e '^$' | sort | uniq -c | sort -n
else
- cat
+ sort
fi
}