2023-02-06 22:47:13 +08:00
|
|
|
|
[#]: subject: "Wordsmith on the Linux command line with dict"
|
|
|
|
|
[#]: via: "https://opensource.com/article/23/2/linux-dict-command"
|
|
|
|
|
[#]: author: "David Both https://opensource.com/users/dboth"
|
|
|
|
|
[#]: collector: "lkxed"
|
2023-02-28 08:47:34 +08:00
|
|
|
|
[#]: translator: "geekpi"
|
2023-03-08 15:27:48 +08:00
|
|
|
|
[#]: reviewer: "wxy"
|
|
|
|
|
[#]: publisher: "wxy"
|
|
|
|
|
[#]: url: "https://linux.cn/article-15607-1.html"
|
2023-02-06 22:47:13 +08:00
|
|
|
|
|
2023-03-02 08:48:23 +08:00
|
|
|
|
在 Linux 命令行上使用 dict 文字工具
|
2023-02-06 22:47:13 +08:00
|
|
|
|
======
|
|
|
|
|
|
2023-03-08 15:27:48 +08:00
|
|
|
|
![][0]
|
|
|
|
|
|
|
|
|
|
> Linux 上的 dict 命令对作家来说非常有用,可以为他们的选词提供大量的字典和同义词。
|
|
|
|
|
|
2023-03-02 08:48:23 +08:00
|
|
|
|
作为一个作家,我经常需要确定单词的正确拼写或定义。我还需要使用词库来寻找替代词,这些词的内涵可能与我可能使用的词有些不同。因为我经常使用 Linux 命令行和文本模式工具来完成我的大部分工作,所以使用命令行词典是有意义的。
|
2023-02-06 22:47:13 +08:00
|
|
|
|
|
2023-03-02 08:48:23 +08:00
|
|
|
|
我非常喜欢使用命令行,原因有很多,其中最主要的原因是它对我来说更有效率。它也比任何一本或多本实体纸质字典,都要全面得多。我使用 Linux 的 `dict` 命令已经很多年了,我已经开始依赖它了。
|
2023-02-06 22:47:13 +08:00
|
|
|
|
|
2023-03-02 08:48:23 +08:00
|
|
|
|
### 在 Linux 上安装 dict
|
2023-02-06 22:47:13 +08:00
|
|
|
|
|
2023-03-08 15:27:48 +08:00
|
|
|
|
`dict` 程序在 Fedora 上没有默认安装,但它很容易安装。以下是如何在 Fedora 或类似发行版上安装:
|
2023-02-06 22:47:13 +08:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
$ sudo dnf install dictd
|
|
|
|
|
```
|
|
|
|
|
|
2023-03-02 08:48:23 +08:00
|
|
|
|
在 Debian 和类似发行版上,你还必须安装字典定义:
|
|
|
|
|
|
2023-02-06 22:47:13 +08:00
|
|
|
|
```
|
|
|
|
|
$ sudo apt install dictd dict-gcide
|
|
|
|
|
```
|
|
|
|
|
|
2023-03-08 15:27:48 +08:00
|
|
|
|
不需要额外的配置。这个非常简单的 `/usr/share/doc/dictd/dict1.conf` 文件指定了字典数据库的远程服务器。这个工具使用字典服务器协议(DICT),端口为 2628。
|
2023-02-06 22:47:13 +08:00
|
|
|
|
|
2023-03-02 08:48:23 +08:00
|
|
|
|
### 在 Linux 上使用 dict
|
2023-02-06 22:47:13 +08:00
|
|
|
|
|
2023-03-02 08:48:23 +08:00
|
|
|
|
在终端会话中,以非 root 用户的身份,输入 `dict <word>` 来获取一个或多个字典和词库的定义列表。例如,以这种方式查找 `memory` 这个词。
|
2023-02-06 22:47:13 +08:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
$ 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
|
|
|
|
|
```
|
|
|
|
|
|
2023-03-02 08:48:23 +08:00
|
|
|
|
为了节省空间,我删去了这个结果的大部分内容,同时留下了足够的信息,以提供一个典型结果的概念。你也可以用双引号或单引号将多字短语括起来进行查询。
|
2023-02-06 22:47:13 +08:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
$ dict "air gapped"
|
|
|
|
|
```
|
|
|
|
|
|
2023-03-02 08:48:23 +08:00
|
|
|
|
### 字典
|
2023-02-06 22:47:13 +08:00
|
|
|
|
|
2023-03-08 15:27:48 +08:00
|
|
|
|
`dict` 命令使用一些在线字典,包括法律和技术字典。许多语言的字典也是可用的。你可以“列出”可用的字典数据库,如下面所示:
|
2023-02-06 22:47:13 +08:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
$ 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>
|
|
|
|
|
```
|
|
|
|
|
|
2023-03-02 08:48:23 +08:00
|
|
|
|
你可以用 `-d` 选项指定单个字典:
|
2023-02-06 22:47:13 +08:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
$ dict -d gcide
|
|
|
|
|
```
|
|
|
|
|
|
2023-03-02 08:48:23 +08:00
|
|
|
|
### 总结
|
2023-02-06 22:47:13 +08:00
|
|
|
|
|
2023-03-02 08:48:23 +08:00
|
|
|
|
有时使用词库中的词汇并不是最好的写作方法,因为它可能会混淆你的意思。但我确实发现 `dict` 命令在为特定的意思选择最好的词方面有极大的帮助。它还能确保我使用的单词拼写正确。
|
2023-02-06 22:47:13 +08:00
|
|
|
|
|
2023-03-08 15:27:48 +08:00
|
|
|
|
关于 dict 的信息很匮乏。 这个 URL [http://www.dict.org/][1] 只提供了一个基于网络的字典界面。手册页涵盖了语法。但是这个命令是一个有用的、有趣的命令,可以随身携带。我承认在发现 `dict` 命令后,我花了很多时间尝试不同的东西,看看结果会是什么。我就是那个通读百科全书和字典的孩子。是的,我是_那个_孩子。除了在写作或阅读时是一个有用的工具外,`dict` 也可以是一个有趣的工具来满足一下好奇心。
|
2023-02-06 22:47:13 +08:00
|
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
via: https://opensource.com/article/23/2/linux-dict-command
|
|
|
|
|
|
|
|
|
|
作者:[David Both][a]
|
|
|
|
|
选题:[lkxed][b]
|
2023-03-02 08:48:23 +08:00
|
|
|
|
译者:[geekpi](https://github.com/geekpi)
|
2023-03-08 15:27:48 +08:00
|
|
|
|
校对:[wxy](https://github.com/wxy)
|
2023-02-06 22:47:13 +08:00
|
|
|
|
|
|
|
|
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
|
|
|
|
|
|
|
|
|
[a]: https://opensource.com/users/dboth
|
|
|
|
|
[b]: https://github.com/lkxed
|
|
|
|
|
[1]: http://www.dict.org/
|
2023-03-08 15:27:48 +08:00
|
|
|
|
[0]: https://img.linux.net.cn/data/attachment/album/202303/08/152653jojqqmv7x7wxzox7.jpg
|