> Q: What did the Zen Master say to the hotdog vendor?
>
> A: "Make me one with everything."
>
I liked this so much that I clapped. But with one hand.
> Come on folks, it doesn't get any better than this!
I really liked the joke actually. It was the only original,
humourous one in the last 500 or so.
ObUsefulThing:
I'm not making any claims for speed or portability of this thing, but
it works on my ultrix system. (In fact, I'm almost sure it didn't
work on AIX 3. Another gleaming example of *ix portability!)
I was frustrated with the fortune files that needed complicated line
prefixes (e.g. %n before each line of the nth fortune) to work, and a
hard-coded no. of fortunes in the script.
Your fortunes file (call it ".fortunes") simply looks like this:
----------------------------------------------------------------------
"Once you have pulled the pin on Mr. Grenade, he is no longer your friend."
-- Usenet (David C. Barber?)
#
"A one line fortune."
#
"She's big as life
and twice as natural."
--Lewis Carroll
----------------------------------------------------------------------
... and so forth, as many fortunes of any length as you'd like.
(Be careful of the '#' delimiters...it seemed like a fairly
safe character.)
Then you need to execute the following script (e.g. in your .login
file):
----------------------------------------------------------------------
:
# gives you a humourous login message
#
# works on a file (".fortunes" in the current
# directory) with "#" at the beginning and
# at the end, and with #s separating the messages
#
# -----------How it works-----------
# 1. using awk, determine the number of fortunes in
# the file (is there a better way to do this?)
# awk lets us use '#' as the field delimiter,
# ignoring cr/lfs)
#
nfort=`awk 'BEGIN{RS="#"}END{print NR}' .fortunes`
#
# 2. select a random number between 0 and the no of
# lines in the file
#
a=`expr $$ % $nfort`
#
echo $a":"$nfort
#
# 3. now we can simply print the 'n'th fortune!
#
awk 'BEGIN{RS="#"}NR == NREC' NREC=$a .fortunes
#
----------------------------------------------------------------------
I welcome any mail on portability or speed enhancement improvements.
But since I am very stupid the script should be less than 10 lines
of (executable) shell (or awk or sed ...) commands.
--
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Tim P Scott . . sending from: Spectragraphics Corp.
9707 Waples St., San Diego CA 92121 [USA]+619-587-6834
Try: sc...@spectra.com or ...{ucsd!}nosc!spectra!scott
I never sausage bad humor -- weiner say such things around here, but I
mustard this sorta thing a 1000 times on the Net ...
But let's move on, I koan take no more. That was Zen -- this is Tao.
Senor Coyote
--
+----------------------------------------------------------------------------+
| Greg Goebel NET: gvg@hpisla |
| Hewlett-Packard HP DESK: GREG GOEBEL / HP0900 / EM |
| MSO Marketing PHONE: Telnet/303 679-3424 |
| POB 301 / MS-CU312 / Loveland CO 80539 FAX: Telnet/303 679-5957 |
+----------------------------------------------------------------------------+
I am moving all day
And not moving at all
I am the moon under the waves
That go ever rolling.