Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
1  
I think this should go to Super User. At the very least it should be a wiki article. –  John Gardeniers Aug 17 '09 at 9:27
add comment

2 Answers 2

It can be used for generating names for temporary files and directories (something like mktemp is even better, but may not always be available).

share|improve this answer
    
Interesting - I imagine if you're creating a lot of temporary stuff then a random number concatenated to say the date or appname, may be useful. Thx for the input sleske. –  DBMarcos99 Aug 17 '09 at 18:37
add comment

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).

share|improve this answer
    
$$ is usually used for this instead of $RANDOM - it's more portable and as a bonus, monotonically increasing. –  pjz Sep 17 '09 at 22:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.