Pull random line from a file
biffcool at zombieworld.com
Fri Sep 6 09:12:22 PDT 2002
On Fri, 6 Sep 2002 17:33:01 +0200, Conrad Newton <conrad.newton at broadpark.no> wrote:
> If you find yourself doing a lot of scripting,
> you may prefer the $() notation to the backticks ``.
> The $() notation, e.g.
Thanks, I knew there was another notation for it, but I couldn't remember what it was.
Hell with that I can do it in one line:
RNDLINE=$(sed -n $(expr $RANDOM % $(grep -c --regexp=.* $FILENAME))p $FILENAME)
Which is far better :)
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