summaryrefslogtreecommitdiff
path: root/hangman.sh
diff options
context:
space:
mode:
Diffstat (limited to 'hangman.sh')
-rwxr-xr-xhangman.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/hangman.sh b/hangman.sh
new file mode 100755
index 0000000..5e0e138
--- /dev/null
+++ b/hangman.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+word=$1
+not=$2
+flag=$3
+
+temp=`mktemp`
+
+grep -i '^'"$word"'$' /usr/share/dict/words | grep -iv "['$not]" > "$temp"
+
+if [ "$flag" = '-l' ]; then
+ cat "$temp" | tr 'A-Z' 'a-z' | sed 's/\(.\)/\1\n/'g | sort | uniq -c | sort -n
+else
+ cat "$temp"
+fi
+rm "$temp"