Created
March 15, 2020 00:02
-
-
Save mshuler/e7223ae59b914e12740d17647b049911 to your computer and use it in GitHub Desktop.
Generate random password string on the CLI
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 | |
# Generate random password string from all printable, non-space | |
# characters, using passed argument for number of characters, | |
# defaulting to a 16-character string. For example: | |
# $ randpw | |
# XC6Jo]2fj&f4E45n | |
# $ randpw 24 | |
# :U)#J]b5[0mg)Wp@M\)l`$\y | |
function randpw() { | |
tr -dc '[:graph:]' < /dev/urandom \ | |
| head -c ${1:-16} | |
echo | |
} | |
randpw ${1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment