On Sun, Aug 22, 2004 at 02:35:14PM -0500, Lance Hoffmeyer wrote: > Hello all, > > I would like to write a script that will select N number of > random lines in a file. Any suggestions on how to do this?
Here's one that prints random lines of files, ensuring not to overshoot the known length of the number of lines in the file: sed -n $[ $RANDOM % $(wc -l < $FILE) + 1 ],$[ $RANDOM % $(wc -l < ./foo) + 1 ]p $FILE Where $FILE is the filename. If you want to control the number of lines it will print, change the values. :) -- Thomas Adam -- "Frankly, Mr. Shankly, since you ask. You are a flatulent pain in the arse." -- Morrissey. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]