Created
November 3, 2015 14:25
-
-
Save darookee/bc3d61ab0a5a312834ed to your computer and use it in GitHub Desktop.
Generate random passwords
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 | |
| # | |
| # Usage: ${0} <length> <count> <hex or alpha> | |
| # Example: ${0} 12 1 h | |
| # ${0} 32 2 | |
| # ${0} | |
| alnum="[:digit:][:alpha:]" | |
| hex="a-f[:digit:]" | |
| if [ "${3}" == "h" ]; then | |
| pwtype=$hex | |
| else | |
| pwtype=$alnum | |
| fi | |
| env LC_CTYPE=C tr -dc $pwtype < /dev/urandom | fold -w ${1:-32} | head -n ${2:-1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment