在 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 <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
命令使用一些在線字典,包括法律和技術字典。許多語言的字典也是可用的。你可以「列出」可用的字典資料庫,如下面所示:
$ 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/ 只提供了一個基於網路的字典界面。手冊頁涵蓋了語法。但是這個命令是一個有用的、有趣的命令,可以隨身攜帶。我承認在發現 dict
命令後,我花了很多時間嘗試不同的東西,看看結果會是什麼。我就是那個通讀百科全書和字典的孩子。是的,我是_那個_孩子。除了在寫作或閱讀時是一個有用的工具外,dict
也可以是一個有趣的工具來滿足一下好奇心。
via: https://opensource.com/article/23/2/linux-dict-command
作者:David Both 選題:lkxed 譯者:geekpi 校對:wxy
本文轉載來自 Linux 中國: https://github.com/Linux-CN/archive