Bash-password-genorator: Difference between revisions
Jump to navigation
Jump to search
(Created page with "==Bash version== <pre> #!/bin/bash if -z $1 ; then CHAR=10 else CHAR=$1 fi strings /dev/urandom | grep -o 'alnum:' | head -n ${CHAR} | tr -d '\n'; echo '!' </pre...") |
mNo edit summary |
||
Line 18: | Line 18: | ||
fi | fi | ||
strings /dev/urandom | grep -o '[[:alnum:]]' | head -n ${CHAR} | tr -d '\n'; echo '!' | strings /dev/urandom | grep -o '[[:alnum:]]' | head -n ${CHAR} | tr -d '\n'; echo '!' | ||
</pre> | |||
== Working with both Linux and Mac == | |||
<pre> | |||
cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w 35 | head -n 1 | |||
</pre> | </pre> | ||
[[Category:bash]] | [[Category:bash]] |
Latest revision as of 08:57, 25 October 2023
Bash version
#!/bin/bash if [[ -z $1 ]]; then CHAR=10 else CHAR=$1 fi strings /dev/urandom | grep -o '[[:alnum:]]' | head -n ${CHAR} | tr -d '\n'; echo '!'
Shell version
#!/bin/sh if [ -z $1 ]; then CHAR=10 else CHAR=$1 fi strings /dev/urandom | grep -o '[[:alnum:]]' | head -n ${CHAR} | tr -d '\n'; echo '!'
Working with both Linux and Mac
cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w 35 | head -n 1