Skip to content

Instantly share code, notes, and snippets.

@jakebathman
Created April 25, 2018 21:11
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 jakebathman/dc25166408b8c0e1218978c625adbf93 to your computer and use it in GitHub Desktop.
Save jakebathman/dc25166408b8c0e1218978c625adbf93 to your computer and use it in GitHub Desktop.
Random string generator
# Use these on the command line to generate random strings
# Tested in CentOS and macOS
# All printable characters
head /dev/urandom | LC_CTYPE=C tr -dc "[:print:]" | head -c 32
# Only A-Za-z0-9
head /dev/urandom | LC_CTYPE=C tr -dc "A-Za-z0-9" | head -c 32
# Alphanum with some special characters
head /dev/urandom | LC_CTYPE=C tr -dc 'A-Za-z0-9%^&*()\-=_+' | head -c 32
# Numbers only
head /dev/urandom | LC_CTYPE=C tr -dc 0-9 | head -c 32
# Letters only
head /dev/urandom | LC_CTYPE=C tr -dc A-Za-z | head -c 32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment