Skip to content

Instantly share code, notes, and snippets.

@fnkr
Last active March 31, 2017 08:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fnkr/0906f4dfd4645c5d68431282cade47c8 to your computer and use it in GitHub Desktop.
Save fnkr/0906f4dfd4645c5d68431282cade47c8 to your computer and use it in GitHub Desktop.
Generate random, alphanumeric strings in Bash.
#!/bin/bash
RANDSTR="$(cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | head -c 40)"
@fnkr
Copy link
Author

fnkr commented Mar 2, 2017

FreeBSD-compatible:

head -c 60 /dev/urandom | strings -n1 | tr -dc 'a-zA-Z0-9' | head -c15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment