words 是一个字典文件,通常是一行一个单词,存储路径一般在 /usr/share/dict/words ,如它常用来作为程序中作为单词的拼写检查,当然还有其它的许多的用途。
在 Debian 或 Ubuntu 这些发行版上,字典文件包围 wordlist ,比如运行下面命令可以看到:# apt-get install wordlist
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package wordlist is a virtual package provided by:
wnorwegian 2.0.10-3.2
wswedish 1.4.5-2build1
wbritish-small 6-3
wbritish 6-3
wamerican 6-3
... ...
You should explicitly select one to install.
E: Package wordlist has no installation candidate 可以从中选择相应的安装包进行安装。
在 Fedora 或 Arch 发行版中,一般是以 words 安装包出现。
比如下面命令找出以 abb 开头的单词:# egrep -i "^ab{2}" /usr/share/dict/british-english
Abbas
Abbasid
Abbasid's
Abbott
... ...
判断输入单词是否正确:
[Bash shell] 纯文本查看 复制代码 #!/bin/bash
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
运行输出:# ./spell.sh groad
groad is not a dictionary word
# ./spell.sh net
net is a dictionary word |