//Random Tip
Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow

You are viewing a random entry, refresh your browser to change.

Often it can be handy to have a few files to test another script on. A quick way to do this is to create some empty files with random names:

for ((  i = 0 ;  i < 12;  i++  )); do touch $RANDOM; done


Just change the number (12) to give the required number of files.


View Comments »




Comments 

Add your comment

Comments are currently disabled
sash-kan
for ((  i = 0 ;  i < 12;  i++  )); -- long
for i in $(seq 0 12); -- short
Posted 2008-09-18 13:40:02
John
for i in `seq 12`; do touch $RANDOM; done

is even shorter, but not all systems have the 'seq' command - hence the original can still be useful.
Posted 2008-09-18 14:05:32
neolix
in the same vain as `seq 12` - for in in {1..12}; do touch $RANDOM;done
Posted 2008-10-05 19:13:21
having files named against $RANDOM seems pretty useless for testing :P in any case if you really want random use "mktemp" that is collision-safe at least.
Posted 2009-02-13 00:08:40

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit