aspell命令作用是拼写检查, 目录/usr/share/dict
包括了一些词典文件,如 american-english
cracklib-small
等,aspell检查单词是否在字典里。
1
2
3
4
5
6
7
8
9
|
#!/bin/bash
#文件名: checkword.sh
word=$1
grep "^$1$" /usr/share/dict/british-english -q
if [ $? -eq 0 ]; then
echo $word is a dictionary word;
else
echo $word is not a dictionary word;
fi
|
-q 表示禁止grep产生输出内容;$1代表命令行第一个参数,$标记单词的结束
1
2
3
4
|
$ ./checkword.sh fu
fu is not a dictionary word
$ ./checkword.sh a
a is a dictionary word
|
1
2
3
4
5
6
7
8
9
|
#!/bin/bash
#文件名: aspellcheck.sh
word=$1
output=`echo \"$word\" | aspell list`
if [ -z $output ]; then
echo $word is a dictionary word;
else
echo $word is not a dictionary word;
fi
|