告别信号焦虑!手把手教你用Wi-Fi Scanner 22.08优化家庭网络,榨干每一格信号
2026/5/5 17:03:17
当你拥有从文件中随机选择一行内容的工具时,就能编写各种问答游戏。这里有一个美国 50 个州首府的问答游戏,所需的数据文件state.capitals.txt可从 http://www.nostarch.com/wcss2/ 下载。下载后将文件保存到/usr/lib/games目录。
#!/bin/bash # states--A state capital guessing game. Requires the state capitals # data file state.capitals.txt. db="/usr/lib/games/state.capitals.txt" # Format is State[tab]City. if [ ! -r "$db" ] ; then echo "$0: Can't open $db for reading." >&2 echo "(get state.capitals.txt" >&2 echo "save the file as $db and you're ready to play!)" >&2 exit 1 fi guesses=0; correct=0; total=0 whi