在 Linux 命令行中使用 dict 进行文字处理

Linux 上的 dict 命令对于作家来说非常有用,它可以访问大量的词典和同义词,以供他们选择用词。
9 位读者喜欢这篇文章。
Typewriter in the grass

原始照片由 jetheriot 拍摄。由 Rikki Endsley 修改。CC BY-SA 2.0 许可。

作为一名作家,我经常需要确定单词的正确拼写或定义。 我还需要使用词库来查找可能具有与我可能使用的词略有不同的含义的替代词。 因为我经常使用 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 文件指定了词典数据库的远程服务器。 此工具在端口 2628 上使用词典服务器协议 (DICT)。

在 Linux 上使用 dict

在终端会话中,以非 root 用户身份,键入 dict <word> 以从一个或多个词典和词库中获取定义列表。 例如,以这种方式查找单词 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]
<SNIP>

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
<SNIP>

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,
<SNIP>

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

  memory

     <storage> 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 命令使用多个在线词典,包括法律和技术词典。 词典也适用于多种语言。 您可以 list 可用的词典数据库,如下所示

$ 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
<SNIP>

您可以使用 -d 选项指定单个词典

$ dict -d gcide

总结

有时使用在词库中找到的词语并不是写作的最佳方法,因为它可能会使你的意思模糊不清。 但我确实发现 dict 命令在为特定含义选择最佳词语时非常有用。 它还可以确保我使用的单词拼写正确。

关于 dict 的信息很少。 URL http://www.dict.org/ 仅提供词典的基于 Web 的界面。 man 页面涵盖语法。 但是该命令是一个有用且有趣的命令,可以随手使用。 我承认,在发现 dict 命令后,我花了很多时间只是尝试不同的东西,看看结果会是什么。 我是那个读百科全书和词典的孩子。 是的,我就是那个孩子。 除了作为写作或阅读时的有用工具外,dict 也可以成为满足一点好奇心的有趣工具。

标签
David Both
David Both 是一位开源软件和 GNU/Linux 的倡导者、培训师、作家和演讲者。 自 1996 年以来,他一直从事 Linux 和开源软件方面的工作,自 1969 年以来一直从事计算机方面的工作。 他是“系统管理员的 Linux 哲学”的坚定拥护者和传播者。

2 条评论

很棒的文章! 对于我们这些使用 macOS 的人,您可以使用 Homebrew 包管理器来安装 dict 命令。 打开“终端”应用程序,输入“brew install dict”,然后按回车键。 macOS 下 dict 命令的语法与 Linux 版本基本相同。 再次感谢!

做得好!

Creative Commons License本作品根据知识共享署名-相同方式共享 4.0 国际许可协议获得许可。
© . All rights reserved.