
Here’s a script I keep in ~/bin/randpwd.pl and use frequently to generate random password strings. It prints an 8 character password by default, but you can also specify a different password length on the command line. I left out the capital letter “o” to avoid confusion with the number zero. ;-)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#!/usr/bin/perl -w # /usr/local/bin/randpwd.pl {length} # Generate a random password. # by Jean-Sebastien Morisset (https://surniaulula.com/) use strict; my @chrs = ( 'A'..'N', 'P'..'Z', 'a'..'z', 0..9 ); my $len = defined( $ARGV[0] ) ? int( $ARGV[0] ) : 8; print $chrs[rand @chrs] for 1 .. $len; print "\n"; exit 0; |