It's obviously good for creating dummy data; also can be used for generating passwords (although I believe you have to be careful here as to the true "randomness"). Any other useful uses that you've come across?
It's obviously good for creating dummy data; also can be used for generating passwords (although I believe you have to be careful here as to the true "randomness"). Any other useful uses that you've come across?
It can be used for generating names for temporary files and directories (something like mktemp is even better, but may not always be available).
I'd use it in bash scripts the exact same way you'd use random number generation in other programming languages.
As your comment put it, what if you want to write some data to a file but don't have a good naming scheme? You could just name the file
/tmp/data-$RANDOM.txt
and since you know what$RANDOM
is, you can make note of it in your script and act accordingly.Or maybe you have multiple programs you've spawned off that need to share some secret data that you know you can safely store unencrypted on the file system. Just generate some random number and use that if they need to chat over a secure line so that they can verify the other programs are legitimate (although you should be very careful with an approach like this, security-wise).