Re: select N random lines in a file
From: Adam Funk (a24061_at_yahoo.com)
Date: 08/22/04
- Previous message: Thomas Adam: "Re: XMMS doing strange things"
- In reply to: Lance Hoffmeyer: "select N random lines in a file"
- Next in thread: Kevin Mark: "Re: select N random lines in a file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 22 Aug 2004 19:53:04 GMT To: debian-user@lists.debian.org
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't mind duplicates in the output, read
them into an array of strings then pick N items at random from the
array. If you want to avoid duplicates, read them into a hash so you
can delete each item as it is picked.
-- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
- Previous message: Thomas Adam: "Re: XMMS doing strange things"
- In reply to: Lance Hoffmeyer: "select N random lines in a file"
- Next in thread: Kevin Mark: "Re: select N random lines in a file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|