Re: select N random lines in a file

2004-08-23 Thread Winston Smith
On Sun, Aug 22, 2004 at 02:35:14PM -0500, Lance Hoffmeyer wrote: > 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? This program has the advantage that it doesn't read the whole file into memory, which is important if the fil

Re: select N random lines in a file

2004-08-22 Thread Kevin Mark
On Sun, Aug 22, 2004 at 09:16:37PM +0100, Thomas Adam wrote: > On Sun, Aug 22, 2004 at 04:11:39PM -0400, Travis Crump wrote: > > > That only prints one line whenever the second range number is less than > > the first[which happens roughly half the time][ignoring the fact that > > ./foo should a

Re: select N random lines in a file

2004-08-22 Thread Kevin Mark
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? > > > Lance Hi Lance, any language preference? C,perl, bash? there are 1x 10^6 ways. Is this

Re: select N random lines in a file

2004-08-22 Thread Adam Funk
On Sunday 22 August 2004 20:40, 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? I can't guarantee that this is the best approach, but I would write a small Perl program. If you don'

Re: select N random lines in a file

2004-08-22 Thread Henrik Christian Grove
Lance Hoffmeyer <[EMAIL PROTECTED]> writes: > 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? bogosort -n file | head -N .Henrik -- Henrik Christian Grove [EMAIL PROTECTED] Systems administrator -- To

Re: select N random lines in a file

2004-08-22 Thread Thomas Adam
On Sun, Aug 22, 2004 at 04:11:39PM -0400, Travis Crump wrote: > That only prints one line whenever the second range number is less than > the first[which happens roughly half the time][ignoring the fact that > ./foo should also be $FILE]. Yeah, it's not perfect, but it was just off the top of

Re: select N random lines in a file

2004-08-22 Thread Stefan O'Rear
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? > > Lance One way: - Count lines in file - Pick N line numbers - Show file, filtering out u

Re: select N random lines in a file

2004-08-22 Thread Travis Crump
Thomas Adam wrote: 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 l

Re: select N random lines in a file

2004-08-22 Thread Oliver Elphick
On Sun, 2004-08-22 at 20:35, 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? > Use the rand() function in awk -- Oliver Elphick [EMAIL PROT

Re: select N random lines in a file

2004-08-22 Thread Thomas Adam
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 t