Skip to content

Instantly share code, notes, and snippets.

@squio
Last active May 7, 2021 15:33
Show Gist options
  • Save squio/abb24f5dbdab4f3ea9fd28dd51922266 to your computer and use it in GitHub Desktop.
Save squio/abb24f5dbdab4f3ea9fd28dd51922266 to your computer and use it in GitHub Desktop.
genpass - generate password from command line
#!/bin/sh
### default length
LENGTH=20
### command line
let L="$1"+0
if [ $L -gt 2 ]; then
LENGTH=$L
fi
LC_CTYPE=C
cat /dev/urandom \
| tr -dc [:print:] \
| tr -d '[:space:]\042\047\134' \
| fold -w $LENGTH \
| head -n 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment