Skip to content

Instantly share code, notes, and snippets.

@iandexter
Created January 16, 2010 02:56
Show Gist options
  • Save iandexter/278616 to your computer and use it in GitHub Desktop.
Save iandexter/278616 to your computer and use it in GitHub Desktop.
Generate random strings
#!/bin/bash
usage() {
echo "Usage: `basename $0` [length]"
}
[ $# -gt 1 ] && usage && exit 65
[ $# -eq 0 ] && len=8 || len=$1
strings /dev/urandom | grep -o '[[:alnum:]]' | head -n $len | tr -d '\n'; echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment