

The for loop runs 12 times, so you get 12 passwords.

Finally, cut slices off 12 characters to end with a 12-character password. The job of sed seems to be some further transformation so that the letters are mixed upper and lower case. The uuencode command can be obtained by installing the sharutils package.

The feedback messages from dd are stripped out, and then the characters are passed on to uuencode, whose job it is to transform the characters so that all are printable (i.e., no control characters). You may have seen dd used to copy one disk to another, but in this case, it is used to generate one block of random characters with dev/urandom. The "meat" of the script is in the line beginning with do dd. I don't know all the details of how this works, but I have done a bit of research and experimentation. #!/usr/bin/env shįor ((n=0 n /dev/null | uuencode -m - | sed -ne 2p | cut -c-12 Full disclosure: I found most of this script posted somewhere and made a minor modification to it. My mind often seems to draw a blank when I have to create a new login, and this short Bash script fills that void. Periodically, I need to come up with new passwords, some of which need to be more secure than others.
