Created
April 26, 2019 17:19
-
-
Save louischan/04e0e6526dccb14fd109f31118064f2f to your computer and use it in GitHub Desktop.
Minimal bash shell random string/number generator
This file contains hidden or 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
#!/bin/bash | |
openssl rand -base64 "${2:-50}" | tr -cd "[:${1:-digit}:]"; echo | |
# Usage examples: | |
# rand [digit | alpha | alnum] [num_bytes] | |
# $ rand | |
# $ rand alnum | |
# $ rand digit 200 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment