January 2004
Intermediate to advanced
368 pages
7h 25m
English
Once you have a tool for choosing a line randomly from a file, as we have with Script #76, Displaying Random Text, there's no limit to the type of quiz games you can write. In this instance, I've pulled together a list of the capitals of all 50 states in the United States of America; this script randomly chooses one, shows the state, and asks the user to type in the matching capital.
#!/bin/sh # states - A state capital guessing game. Requires the state capitals # data file at http://www.intuitive.com/wicked/examples/state.capitals.txt. db="/usr/lib/games/state.capitals.txt" randomquote="$HOME/bin/randomquote.sh" # Script #76 if [ ! -r $db ] ; then echo "$0: Can't open $db for reading." >&2 echo "(get http://www.intuitive.com/wicked/examples/state.capitals.txt" ...
Read now
Unlock full access