Password string generation I'm trying to create passwords using the following snippet to match a custom password policy. I've added three gtr statements, at the end of the string, to guarantee my password policy is met.

foo=$(gtr -dc 'a-zA-Z0-9' &lt; /dev/urandom | head -c 96;
gtr -dc 'A-Z' &lt; /dev/urandom | head -c 1;
gtr -dc 'a-z' &lt; /dev/urandom | head -c 1;
gtr -dc '0-9' &lt; /dev/urandom | head -c 1);
echo $foo 


Could this code be simplified?
I don't understand why you need GNU tr for this task. The macOs tr should work equally well.

For passwords, you should use /dev/random instead of urandom.

It's a funny password policy if it really requires the password to be 99 characters long. At that length, it doesn't matter anymore whether the password contains a digit or not because such a long password, if generated by a strong random generator, cannot be guessed.

The code in itself is fine. I would indent it differently, though, lining up all four calls to tr. Writing a function to eliminate the code duplication is probably overkill.