Skip to content

Instantly share code, notes, and snippets.

@brwyatt
Last active August 29, 2015 14:00
Show Gist options
  • Save brwyatt/c2e7d287e98420d20b0b to your computer and use it in GitHub Desktop.
Save brwyatt/c2e7d287e98420d20b0b to your computer and use it in GitHub Desktop.
Generate a 4-6 word passphrase similar to https://xkcd.com/936/
#!/bin/bash
WORDLIST=$(grep -iv '[^abcdefghijklmnopqrstuvwxyz]' /usr/share/dict/words)
COUNT="$(echo "($RANDOM%3)+4"|bc)"
WORDCOUNT="$(echo "$WORDLIST"|wc -l)"
LC_CTYPE=C
x=0
while [ $x -lt $COUNT ]; do
echo -n $(echo "$WORDLIST"|tail -n$(echo "($RANDOM % $WORDCOUNT)+1"|bc)|head -n1|sed -e 's/\b\(.\)/\u\1/')
x=$(echo "$x + 1"|bc)
done
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment