I was searching for a cmd to generate random passwords, and got stuck on this one : echo `< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c6`I've read the documentation of urandom, tr and head. But could you explain step by step how all these are linked in this cmd ?I've tried echo `< /dev/urandom` to experiment, and my terminal just crashed !
Pretty tricky cmd
shell;command;pipe
First, I'd guess the command uses echo `...` for the sole purpose of sticking a newline at the end of the output. It doesn't seem have any other effect.That reduces the actual command to:< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c6tr -dc _A-Z-a-z-0-9 deletes every character from the input except for those given (underscore, alphabets and digits, and the hyphen, because the author added extra hyphens). < /dev/urandom indicates tr is reading in from /dev/urandom. Finally, head -c6 extracts the first 6 characters that are output by tr.On the whole, it is a ridiculous way to generate passwords.