DEV Community

loading...

Discussion on: Bash random password generator

Collapse
arifmahmudrana profile image
ARIF MAHMUD RANA

Alex why are you printing printf "$pass_output\n" where are you setting pass_output? This wasn't necessary. Also I think for script it's best to output the only intended things so that output can be piped you implementation doesn't suit that e.g I could have copied the output of script or use it for automation but this is not possible. Also why use clear printf with new line. This are all unnecessary staffs. For me short and simple

#!/bin/bash
read -p "How many characters you would like the password to have? " pass_length
tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' </dev/urandom | head -c pass_length
Enter fullscreen mode Exit fullscreen mode
Collapse
alexgeorgiev17 profile image
Alex Georgiev Author

Good call, Arif! That was left over from the first version of the script which was later on changed! Thanks for pinpointing this.