如何在Linux上通过命令行查找字典如何在Linux上通过命令行查找字典如何在Linux上通过命令行查找字典如何在Linux上通过命令行查找字典
  • 文章
  • 正则表达式
    • 工具
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容
发表 admin at 2025年2月28日
类别
  • 未分类
标签

如何在Linux上通过命令行查找字典

如果您需要查找单词定义,可以参考网络上的任何在线词典。但是,如果您的 Linux 上没有安装 X11,或者没有网络连接怎么办?那么您可能必须求助于离线命令行词典工具(如果有的话)。

在 Linux 上通过命令行查找字典的一种方法是在本地设置 dictd,它是一个字典数据库服务器。 dictd 使用词典服务器协议 (DICT) 允许客户端通过网络从词典数据库查找词典定义。如果在本地主机上设置了 dictd 守护进程,则可以离线访问字典。 dictd 附带一个名为 dict 的命令行客户端。

在 Linux 上安装 dictd

在 Ubuntu 或 Debian 上安装 dictd


$ sudo apt-get install dictd

安装dictd后,还需要安装词典才能使用。如果您安装任何新词典,dictd 将自动重新启动以重新加载其词典数据库。


$ sudo apt-get install dict-gcide  (English dictionary)
$ sudo apt-get install dict-moby-thesaurus (Thesaurus dictionary)

还有许多其他多语言词典可用。例如:


sudo apt-cache search "dict package"

dict-freedict-eng-ara - Dict package for English-Arabic Freedict dictionary
dict-freedict-eng-cro - Dict package for English-Croatian Freedict dictionary
dict-freedict-eng-cze - Dict package for English-Czech Freedict dictionary
dict-freedict-eng-deu - Dict package for English-German Freedict dictionary
dict-freedict-eng-fra - Dict package for English-French Freedict dictionary
dict-freedict-eng-hin - Dict package for English-Hindi Freedict dictionary
dict-freedict-eng-hun - Dict package for English-Hungarian Freedict dictionary
dict-freedict-eng-iri - Dict package for English-Irish Freedict dictionary
dict-freedict-eng-ita - Dict package for English-Italian Freedict dictionary
dict-freedict-eng-lat - Dict package for English-Latin Freedict dictionary
dict-freedict-eng-nld - Dict package for English-Dutch Freedict dictionary
dict-freedict-eng-por - Dict package for English-Portuguese Freedict dictionary
dict-freedict-eng-rom - Dict package for English-Romanian Freedict dictionary
dict-freedict-eng-rus - Dict package for English-Russian Freedict dictionary
dict-freedict-eng-scr - Dict package for English-Serbo-Croat Freedict dictionary
dict-freedict-eng-spa - Dict package for English-Spanish Freedict dictionary
dict-freedict-eng-swa - Dict package for English-Swahili Freedict dictionary
dict-freedict-eng-swe - Dict package for English-Swedish Freedict dictionary
. . .

在 CentOS、RHEL 或 Fedora 上安装 dictd


$ sudo yum install dictd dict

与基于 Ubuntu/Debian 的系统类似,您也可以使用 yum 命令安装任何必要的词典。

使用dictd查找字典

现在您可以使用名为 dict 的命令行客户端来访问 dictd 服务器进行字典查找。

要检查 dictd 服务器是否正在运行以及哪些字典数据库可用,请运行以下命令。在此示例中,有两个词典可用。


$ dict -I

  dictd 1.12.0/rf on Linux 3.2.0-29-generic-pae
  On my_host: up 95.000, 2 forks (75.8/hour)
  
  Database      Headwords         Index          Data  Uncompressed
  gcide              203645       3859 kB         12 MB         38 MB
  moby-thesaurus      30263        528 kB         10 MB         28 MB

要使用特定词典(例如,gcide)查找单词定义:


$ dict -d gcide [word]

如果您没有使用-d选项指定任何数据库,dictd将搜索所有可用的数据库并返回所有匹配的定义。

为了方便起见,您可以设置别名来查找特定数据库的单词定义。例如,作为命令行同义词库,您可以将以下别名添加到~/.bashrc


alias thrus='dict -d moby-thesaurus'

然后您可以使用以下命令查找单词的同义词/反义词:


$ thrus cryptography

1 definition found

From Moby Thesaurus II by Grady Ward, 1.0 [moby-thesaurus]:

  48 Moby Thesaurus words for "cryptography":
     cipher, code, coded message, coup de plume, criticism,
     cryptanalysis, cryptoanalysis, cryptoanalytics, cryptogram,
     cryptograph, cryptographer, cryptology, diagnostics, engrossment,
     epigraphy, exegetics, hermeneutics, ink spilling, inkslinging,
     inscription, invisible ink, lettering, lexicography,
     literary criticism, macrography, metoposcopy, micrography,
     oneirology, paleography, pathognomy, pen, pen-and-ink,
     pencil driving, physiognomics, physiognomy, scrivenery, scrivening,
     secret language, secret writing, semeiology, semeiotics,
     sympathetic ink, symptomatology, textual criticism, tropology,
     typewriting, typing, writing
©2015-2025 艾丽卡 support@alaica.com