I learned this a while back and use it occasionally when I need random text, for file names or just for filler.
But here’s a small trick you can do with it.
< /dev/urandom tr -dc A-Za-z0-9
You should get a high speed stream of …
Or something like it. Press CTRL+C to get your life back.
What the heck just happened? You just generated random text, in only uppercase and lowercase letters, numbers.
No nonprintable, special or control characters. Nothing from extended character sets or command sequences. Just random noise, filtered down to basic characters.
“Well gee,” you’re thinking. “Thanks for that clever little tip, K.Mandla.” 🙄
Yes, it is a clever little tip, because with this you can …
< /dev/urandom tr -dc A-Za-z0-9 | head -c10 ; echo
Generate random passwords for new user accounts, without relying on the Internet.
What else? How about …
mv testfile.txt "`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`.txt"
Scramble file names.
Taking it a step further …
tar -cvvf "`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`.tar" testfile.txt
Package files with random names in one quick swoop … if you’re paranoid, of course.
Don’t stop there. Dump exactly a specific number of printable characters into a file. Make text noise for statistical purposes, or for graphic effect. Generate six-digit hexadecimal values and force-feed them into
xsetroot. Collect only certain numbers. Only lowercase letters. Make fake phone numbers to give to creepy guys. The list goes on.
This isn’t much in the way of a tutorial for
head for that matter, and I didn’t want it to be. There are plenty of sites out there that can teach you more.
This just shows a fairly basic task that is made very easy with a collection of fundamental tools. How you use it is up to you. 🙂