Created
July 14, 2014 16:48
-
-
Save kennwhite/b9f9b3cf49f876b332fd to your computer and use it in GitHub Desktop.
Bash snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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