Grab a random fortune from thinkgeek

Feb 07, '03 10:04:36AM

Contributed by: pdxguy

No practical purpose to this tip, but it does have entertainment value. This little shell script fetches and parses a fortune from the thinkgeek site. Enjoy!

#!/bin/sh
#
# fetch a fortune from thinkgeek
#

curl -s http://www.thinkgeek.com/fortune.shtml | \
sed -n '/(refresh for another)/,/table\>/p' | \
sed -n '/<p>/,/<\/p>/{/[.]/p; }' | \
sed '{/^<[/]*p>/d; s/<[BbRr]*>//g; s/<\;/</g; s/>\;/>/g; }'
Occassionally a blank one is returned; just try again.

[Editor's note: Make sure you make the script executable (chmod 755 script_name), and this worked for me when tested (and some of them are quite humorous).]

Comments (13)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030207070436563