第三章:Creating Utilities--25.检查单个词的拼写

一个检查单词拼写的小程序。非常简单。

代码:

 1 #!/bin/sh
 2 
 3 spell="ispell -l"
 4 
 5 if [ $# -lt 1 ]; then
 6     echo "Usage: `basename $0` word or words" >&2
 7     exit 1
 8 fi
 9 
10 for word
11 do
12     if [ -z $(echo $word | $spell) ]; then
13         echo "$word:    spelled correctly."
14     else
15         echo "$word:    misspelled."
16     fi
17 done
18 
19 exit 0

我实验了下,输入任意一个单词,都正确。奇怪。

posted @ 2013-01-05 10:42  十舍七匹狼  阅读(119)  评论(0编辑  收藏  举报