Created
October 22, 2015 17:48
-
-
Save arosemena/d2cd8394d2e56adb0dbc to your computer and use it in GitHub Desktop.
Generates a random password in bash, can be passed a parameter for length of said password, defaults to 30 characters if no parameter or if parameter isn't a number
This file contains 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
case $1 in | |
''|*[!0-9]*) n=30 ;; | |
*) n=$1 ;; | |
esac | |
</dev/urandom tr -cd 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$@!' | head -c$n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment