曲径通幽论坛

 找回密码
 立即注册
搜索
查看: 3371|回复: 0
打印 上一主题 下一主题

字典(words)

[复制链接]

4918

主题

5880

帖子

3万

积分

GROAD

曲径通幽,安觅芳踪。

Rank: 6Rank: 6

积分
34387
跳转到指定楼层
楼主
发表于 2012-3-26 11:34:58 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
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
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|曲径通幽 ( 琼ICP备11001422号-1|公安备案:46900502000207 )

GMT+8, 2024-5-19 18:07 , Processed in 0.078720 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表