I'm trying to get past the "lack" of a good terminal tool on OS X to generate passwords. This script is a mix from various sources and already done debug from my side (here, here, here and here too)
pass=`LC_CTYPE=C < /dev/urandom tr -cd [:graph:] | tr -d '\n' | head -c 32`
echo $pass
I opted for the head -c 32
method instead of the fold -w 32
method because head seems more clear to me after reading their corresponding man page, and because when I use fold, the script just "hangs" (never stop loading).
I did clearly understood the -c flag of head is for a number of bytes and not characters and that is why I sometimes have more than 32 characters in my resulting password.
The question being, is there a way to replace head to have 32 characters? (I would accept using fold, of course if you explain me why it does not work and rephrase the use of fold -w so I can understand it clearer than with the description coming from the man).
Example of problematic return :
^[[A]S9,Bx8>c:fG)xB??<msm^Ot|?C()bd] # 36 characters, sadly