Previous | Next

$HOME/bin/wargames code

echo -n "Would you like to play a game? "
read x

x=`echo $x | sed 's/[^-a-z0-9]//g'`

if [ -f /usr/games/$x ] ; then
	tput clear
	exec /usr/games/$x
else
	ls /usr/games
	exec cat <<QUOTE
A strange game.
The only winning move is
not to play.
QUOTE
fi
exit 0
How do you list the games available?

This is a shell script, so it it the same way you would from a shell.