Path: utzoo!utgpu!jarvis.csri.toronto.edu!torsqnt!lethe!tvcent!andrew From: andrew@tvcent.uucp (Andrew Cowie) Newsgroups: alt.sources.wanted Subject: Re: Printing of a random quote. Summary: fortune script Message-ID: <1989Dec19.181040.1554@tvcent.uucp> Date: 19 Dec 89 18:10:40 GMT References: <1989Dec16.064319.21721@agate.berkeley.edu> Reply-To: andrew@tvcent.UUCP (Andrew Cowie) Distribution: na Organization: TVC Enterprises Lines: 43 In article <1989Dec16.064319.21721@agate.berkeley.edu> c60c-4ay@e260-1b (Raja S Kushalnagar) writes: > (lines deleted) >and so on. I could write a C program to print a quote at random. But I was >wondering if it could be done with Unix commands or awk alone. Could it? Yes. A while ago a small script was posted that got a random quote from a file of star trek quotes. Here is the script: -------- # # fortune.sh - uses $$ for rand. # a=`expr $$ % 400` expr " $a" : '.*\(.....\)' | \ join -t% -o 2.2 - $HOME/bin/stquotes -------- It operates on a file of the following format: (there were 400 originally, I figured that you didn't need the whole file :-) -------- 0%Star Trek Lives! 1%Schshschshchsch. 1% -- The Gorn, "Arena," stardate 3046.2. 2%Live long and prosper. 2% -- Spock, "Amok Time," stardate 3372.7. 3%Totally illogical, there was no chance. 3% -- Spock, "The Galileo Seven," stardate 2822.3. 4%All your people must learn before you can reach for the stars. 4% -- Kirk, "The Gamesters of Triskelion," stardate 3259.2. 5%We have found all life forms in the galaxy are capable of 5%superior development. 5% -- Kirk, "The Gamesters of Triskelion," stardate 3211.7. -------- Note that quotes can be of any length. I hope this works for what you are trying to do. > Raja S Kushalnagar. -- Andrew F. Cowie at TVC Enterprises, Toronto, Canada. uunet!mnetor!lethe!tvcent!andrew andrew@tvcent.uucp