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 impor
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
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
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
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 admi
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
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 f
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
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
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 th
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
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
On Mon, Jul 02, 2001 at 01:46:29PM -0400, Steven Smolinski wrote:
> On Mon, Jul 02, 2001 at 11:24:40PM +0200, Martin F. Krafft wrote:
> > also sprach Joost Kooij (on Mon, 02 Jul 2001 11:15:38PM +0200):
> > > perl -e 'print map {$_->[1]} sort {$a->[0]<=>$b->[0]} map {[rand,$_]} <>'
> > > file
> >
also sprach Steven Smolinski (on Mon, 02 Jul 2001 02:47:49PM -0400):
> Huh? I thought you wanted one random line chosen out of several?
yeah well, so did i. but in retrospect, for a random playlist of
albums for a custom script to be used with mpg123, permutations make
more sense.
but i still do
On Tue, Jul 03, 2001 at 12:23:20AM +0200, Martin F. Krafft wrote:
> also sprach Steven Smolinski (on Mon, 02 Jul 2001 01:46:29PM -0400):
> > That algorithm is one of the purest distillations of beauty I've ever
> > seen. :-) Remember, the perlfaq is far more peer-reviewed than almost
> > any othe
also sprach Steven Smolinski (on Mon, 02 Jul 2001 01:46:29PM -0400):
> That algorithm is one of the purest distillations of beauty I've ever
> seen. :-) Remember, the perlfaq is far more peer-reviewed than almost
> any other source of info.
okay, okay. i believe you. did you give me a link for t
On Mon, Jul 02, 2001 at 11:24:40PM +0200, Martin F. Krafft wrote:
> also sprach Joost Kooij (on Mon, 02 Jul 2001 11:15:38PM +0200):
> > perl -e 'print map {$_->[1]} sort {$a->[0]<=>$b->[0]} map {[rand,$_]} <>'
> > file
>
> that's perfect!
>
> the other perl algorithm permitted did a scan through
also sprach Joost Kooij (on Mon, 02 Jul 2001 11:15:38PM +0200):
> perl -e 'print map {$_->[1]} sort {$a->[0]<=>$b->[0]} map {[rand,$_]} <>' file
that's perfect!
the other perl algorithm permitted did a scan through the file,
halting on a given line according to a random number. i may well be
wron
On Sun, Jul 01, 2001 at 05:15:13PM +0200, Martin F. Krafft wrote:
> hey,
> do you guys know of a smart way to access random lines in a file? so
> if a file had lines 1-5, 5 random reads would return something like
> line3, line1, line2, line5, line4? you get the picture...
also sprach Thomas J. Hamman (on Sun, 01 Jul 2001 01:32:54PM -0400):
> I like Python. :)
mailman is written in python, right? from my experience, python
scripts always take 1-2 seconds to load before they execute. that's
kind of a pain.
i don't know how python and shell interact - since i plan to
On Sun, Jul 01, 2001 at 06:12:49PM +0200, Martin F. Krafft wrote:
> > from random import *
> > from linecache import *
> > print getline('~/.muttrc',randrange(1,20))
>
> except that hardcodes the file length, does it not?
Yep, like I said it was a quickie example. Here's something that
wouldn't
"Martin F. Krafft" <[EMAIL PROTECTED]> wrote:
> also sprach Thomas J. Hamman (on Sun, 01 Jul 2001 11:58:32AM -0400):
> > What exactly is this for? You could use fortune and strfile. Make
> > the text file with a % symbol between each selection, like this:
>
> a list of albums that i have on mp3
also sprach Thomas J. Hamman (on Sun, 01 Jul 2001 11:58:32AM -0400):
> What exactly is this for? You could use fortune and strfile. Make the
> text file with a % symbol between each selection, like this:
a list of albums that i have on mp3 format.and
the desire to have a script that play
On Sun, Jul 01, 2001 at 05:15:13PM +0200, Martin F. Krafft wrote:
> hey,
> do you guys know of a smart way to access random lines in a file? so
> if a file had lines 1-5, 5 random reads would return something like
> line3, line1, line2, line5, line4? you get the picture...
"Martin F. Krafft" <[EMAIL PROTECTED]> writes:
> do you guys know of a smart way to access random lines in a file?
Hmm, here's a really quick & dirty hack:
$ cat data.txt
foo
bar
baz
quux
$ randline() { head -$(($RANDOM % $(wc -l < $1) + 1)) $1 | tail -1; }
$ ra
hey,
do you guys know of a smart way to access random lines in a file? so
if a file had lines 1-5, 5 random reads would return something like
line3, line1, line2, line5, line4? you get the picture... oh, and that
preferably in shell-script/awk form?
martin; (greetings from the heart
25 matches
Mail list logo