Skip to content

Instantly share code, notes, and snippets.

@kennwhite
Created July 14, 2014 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kennwhite/b9f9b3cf49f876b332fd to your computer and use it in GitHub Desktop.
Save kennwhite/b9f9b3cf49f876b332fd to your computer and use it in GitHub Desktop.
Bash snippets
# Print random number range, Linux or OSX:
# ex: 4707
cat /dev/urandom | od -N2 -An -i|awk -v f=1 -v r=65000 '{printf "%i\n", f + r * $1 / 65536}' | head -n 1
# Create OSX dictionary-based passphrases
# Ex: banish-wilsomeness-piquant
cnt=$( wc -l /usr/share/dict/words | awk '{print $1;}' ); \
for i in {1..3}
do awk -v lineno=$(jot -r 1 1 $cnt) 'lineno==NR{printf $0"-" ;exit}' \
/usr/share/dict/words
done | sed 's/.$//'
# OSX, print random number 1-64K
echo $(jot -r 1 1 $cnt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment