Pull random line from a file

Rob Park rbpark at ualberta.ca
Fri Sep 6 21:51:02 PDT 2002


Alas! Kevan Shea spake thus:
> On Fri, 6 Sep 2002 15:05:17 -0600, Rob Park <rbpark at ualberta.ca> wrote:
> > This is probably better:
> > 
> > RNDLINE=$(sed -n $(expr $RANDOM % $(wc -l $FILENAME))p $FILENAME)
> 
> wc, that's what it was... Thanks.
> 
> This is my favorite list for scripting questions.  I've got an answer in sed, awk, and perl.  Anyone wanna write an INTERCAL answer?

I bet ESR would love to help you with that, considering that he
singlehandedly resurrected the language ;)

(btw, he's very approachable; he actually answers mails from mortals
like us... he might enjoy the challenge, and we might get a kick out of
the resulting code. so ask him already!)

-- 
Rob 'Feztaa' Park
http://members.shaw.ca/feztaa/
--
To generalize is to be an idiot.
		-- William Blake
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe lfs-chat' in the subject header of the message



More information about the lfs-chat mailing list