[ale] Bash question
Fletch
fletch at phydeaux.org
Thu Sep 5 11:06:02 EDT 2002
>>>>> "esoteric" == esoteric <Geoffrey> writes:
esoteric> Understanding that this was originally a bash question,
esoteric> I'd suggest Perl is really the proper tool. I'm just
esoteric> waiting for Fletch to chime in here... :)
Well, if you're going to twist my arm . . .
perl -e '$/="=*\n";while(<>){rand($.)<1&&do{chomp;$l=$_}}print$l' data
That presumes that the "=*\n" delimiter follows items (yours
basically had it preceding it, so you get an empty first record).
It's basically the same format as fortune data files (which use "%\n"
instead; see man strfile, man fortune; replacing "=*\n" with "%\n"
gives you a poor man's fortune replacement). As for an explanation
what it's doing, see perldoc -q 'random line'.
Not that I in any way condone automatically sending people
jokes via email. Come on, it's not the late 1980s any more. :)
--
Fletch | "If you find my answers frightening, __`'/|
fletch at phydeaux.org | Vincent, you should cease askin' \ o.O'
770 933-0600 x211(w) | scary questions." -- Jules =(___)=
770 294-0820 (m) | U
---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be
sent to listmaster at ale dot org.
More information about the Ale
mailing list