在 Linux 命令行上使用 dict 文字工具
创始人
2024-03-02 14:43:25
0

Linux 上的 dict 命令对作家来说非常有用,可以为他们的选词提供大量的字典和同义词。

作为一个作家,我经常需要确定单词的正确拼写或定义。我还需要使用词库来寻找替代词,这些词的内涵可能与我可能使用的词有些不同。因为我经常使用 Linux 命令行和文本模式工具来完成我的大部分工作,所以使用命令行词典是有意义的。

我非常喜欢使用命令行,原因有很多,其中最主要的原因是它对我来说更有效率。它也比任何一本或多本实体纸质字典,都要全面得多。我使用 Linux 的 dict 命令已经很多年了,我已经开始依赖它了。

在 Linux 上安装 dict

dict 程序在 Fedora 上没有默认安装,但它很容易安装。以下是如何在 Fedora 或类似发行版上安装:

$ sudo dnf install dictd

在 Debian 和类似发行版上,你还必须安装字典定义:

$ sudo apt install dictd dict-gcide

不需要额外的配置。这个非常简单的 /usr/share/doc/dictd/dict1.conf 文件指定了字典数据库的远程服务器。这个工具使用字典服务器协议(DICT),端口为 2628。

在 Linux 上使用 dict

在终端会话中,以非 root 用户的身份,输入 dict 来获取一个或多个字典和词库的定义列表。例如,以这种方式查找 memory 这个词。

$ dict memory | less
6 definitions found

From The Collaborative International Dictionary of English v.0.48 [gcide]:

  Memory \Mem"o*ry\, n.; pl. {Memories}. [OE. memorie, OF.
     memoire, memorie, F. m['e]moire, L. memoria, fr. memor
     mindful; cf. mora delay. Cf. {Demur}, {Martyr}, {Memoir},
     {Remember}.]
     [1913 Webster]
     1. The faculty of the mind by which it retains the knowledge
        of previous thoughts, impressions, or events.
        [1913 Webster]

              Memory is the purveyor of reason.     --Rambler.
        [1913 Webster]

     2. The reach and positiveness with which a person can
        remember; the strength and trustworthiness of one's power
        to reach and represent or to recall the past; as, his
        memory was never wrong.
        [1913 Webster]


From WordNet (r) 3.0 (2006) [wn]:

  memory
      n 1: something that is remembered; "search as he would, the
           memory was lost"
      2: the cognitive processes whereby past experience is
         remembered; "he can do it from memory"; "he enjoyed
         remembering his father" [syn: {memory}, {remembering}]
      3: the power of retaining and recalling past experience; "he had


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

  78 Moby Thesaurus words for "memory":
     RAM, anamnesis, anniversaries, archetypal pattern, archetype,
     awareness, celebrating, celebration, ceremony, cognizance,
     commemoration, consciousness, disk memory, dressing ship,


From The Free On-line Dictionary of Computing (30 December 2018) [foldoc]:

  memory

      These days, usually used synonymously with {Random
     Access Memory} or {Read-Only Memory}, but in the general sense
     it can be any device that can hold {data} in
     {machine-readable} format.

     (1996-05-25)


From Bouvier's Law Dictionary, Revised 6th Ed (1856) [bouvier]:

  MEMORY, TIME OF. According to the English common law, which has been altered
  by 2 & 3 Wm. IV., c. 71, the time of memory commenced from the reign of

为了节省空间,我删去了这个结果的大部分内容,同时留下了足够的信息,以提供一个典型结果的概念。你也可以用双引号或单引号将多字短语括起来进行查询。

$ dict "air gapped"

字典

dict 命令使用一些在线字典,包括法律和技术字典。许多语言的字典也是可用的。你可以“列出”可用的字典数据库,如下面所示:

$ dict -D | less
Databases available:
 gcide          The Collaborative International Dictionary of English v.0.48
 wn             WordNet (r) 3.0 (2006)
 moby-thesaurus Moby Thesaurus II by Grady Ward, 1.0
 elements       The Elements (07Nov00)
 vera           V.E.R.A. -- Virtual Entity of Relevant Acronyms (February 2016)
 jargon         The Jargon File (version 4.4.7, 29 Dec 2003)
 foldoc         The Free On-line Dictionary of Computing (30 December 2018)
 easton         Easton's 1897 Bible Dictionary
 hitchcock      Hitchcock's Bible Names Dictionary (late 1800's)
 bouvier        Bouvier's Law Dictionary, Revised 6th Ed (1856)
 devil          The Devil's Dictionary (1881-1906)
 world02        CIA World Factbook 2002
 gaz2k-counties U.S. Gazetteer Counties (2000)
 gaz2k-places   U.S. Gazetteer Places (2000)
 gaz2k-zips     U.S. Gazetteer Zip Code Tabulation Areas (2000)
 fd-hrv-eng     Croatian-English FreeDict Dictionary ver. 0.1.2
 fd-fin-por     suomi-português FreeDict+WikDict dictionary ver. 2018.09.13
 fd-fin-bul     suomi-български език FreeDict+WikDict dictionary ver. 2018.09.13
 fd-fra-bul     français-български език FreeDict+WikDict dictionary ver. 2018.09.13
 fd-deu-swe     Deutsch-Svenska FreeDict+WikDict dictionary ver. 2018.09.13

你可以用 -d 选项指定单个字典:

$ dict -d gcide

总结

有时使用词库中的词汇并不是最好的写作方法,因为它可能会混淆你的意思。但我确实发现 dict 命令在为特定的意思选择最好的词方面有极大的帮助。它还能确保我使用的单词拼写正确。

关于 dict 的信息很匮乏。 这个 URL http://www.dict.org/ 只提供了一个基于网络的字典界面。手册页涵盖了语法。但是这个命令是一个有用的、有趣的命令,可以随身携带。我承认在发现 dict 命令后,我花了很多时间尝试不同的东西,看看结果会是什么。我就是那个通读百科全书和字典的孩子。是的,我是_那个_孩子。除了在写作或阅读时是一个有用的工具外,dict 也可以是一个有趣的工具来满足一下好奇心。


via: https://opensource.com/article/23/2/linux-dict-command

作者:David Both 选题:lkxed 译者:geekpi 校对:wxy

本文由 LCTT 原创编译,Linux中国 荣誉推出

相关内容

使用window.open...
最终页面效果  需求描述:用户需要给当前科技树的节...
2025-01-28 07:11:45
不知道字典键名如何获取其值...
使用字典的values()方法,它将返回字典对象所有的值。代码示例...
2025-01-12 11:01:50
不知道如何使用Spyne将...
可以使用Spyne库将Python字典/JSON转换为XML。下面...
2025-01-12 06:01:53
不知道如何打印包含列表的字...
使用循环遍历字典中的键值对,如果值是列表类型则再次进行循环遍历输出...
2025-01-12 03:31:36
不知道如何从xml文件中填...
以下是一个示例代码,演示了如何从XML文件中填充字典。import...
2025-01-12 03:31:27
不知道键的情况下,可以排除...
在不知道键的情况下,可以使用递归方法来排除深度差异中的字典路径。下...
2025-01-12 02:01:27

热门资讯

使用 KRAWL 扫描 Kub... 用 KRAWL 脚本来识别 Kubernetes Pod 和容器中的错误。当你使用 Kubernet...
Helix:高级 Linux ... 说到 基于终端的文本编辑器,通常 Vim、Emacs 和 Nano 受到了关注。这并不意味着没有其他...
通过 SaltStack 管理... 我在搜索Puppet的替代品时,偶然间碰到了Salt。我喜欢puppet,但是我又爱上Salt了:)...
Epic 游戏商店现在可在 S... 现在可以在 Steam Deck 上运行 Epic 游戏商店了,几乎无懈可击! 但是,它是非官方的。...
如何在 Github 上创建一... 学习如何复刻一个仓库,进行更改,并要求维护人员审查并合并它。你知道如何使用 git 了,你有一个 G...
2024 开年,LLUG 和你... Hi,Linuxer,2024 新年伊始,不知道你是否已经准备好迎接新的一年~ 2024 年,Lin...
Bazzite:专为 Stea... 为 Linux 桌面或者 Steam Deck 做好游戏准备,听起来都很刺激!对于一个专为 Linu...
Motrix:一个漂亮的跨平台... 一个开源的下载管理器,提供了一个简洁的用户界面,同时提供了跨平台操作的所有基本功能。在这里了解关于它...
Bash 脚本中如何使用 he... here 文档 here document (LCTT 译注:here 文档又称作 heredoc ...
使用 dialog 和 jq ... 为何选择文字用户界面(TUI)?许多人每日都在使用终端,因此, 文字用户界面 Text User I...