randpass.sh: Generate semi-aleatory passwords from command line.


/ Published in: Bash
Save to your folder(s)

Example:

$ randpass.sh 32

R"}I3$XzdsC0@KnjjA&U"M4$"lRLkIB@


$ for i in {1..10}; do randpass.sh; done

H,Cqby/2345UgyLWej5k

YV@{N{D


Copy this code and paste it in your HTML
  1. #!/usr/bin/env bash
  2. # randpass.sh
  3. # Generate semi-aleatory passwords from command line.
  4. # Usage:
  5. # ./randpass.sh [NN]
  6. # "NN" is an optional positive integer.
  7. # Default length: 20
  8.  
  9. if [ -z "$1" ]
  10. then
  11. LEN=20
  12. else
  13. LEN=$1
  14. fi
  15.  
  16. echo $(< /dev/urandom tr -cd 'a-zA-Z0-9\<>!".$%&/()=?|@#[]{}-_.:,' \
  17. | head -c $LEN)

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.