Pull random line from a file

Kevan Shea biffcool at zombieworld.com
Fri Sep 6 15:08:35 PDT 2002

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?

Kevan Shea
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