如何在Linux命令列下查詢字典?

來源:互聯網
上載者:User

大多數人在遇到他們不熟悉的單詞時會查詢Google。或者他們用一個最喜歡的線上字典來提供答案。當你在沒有網路連接的時候怎麼辦?或者你只有一個古老的Linux發行版且你沒有GUI介面?你需要離線尋找的話,這裡有一個好的方法。

首先你需要本地設定dictd。dictd 是一個字典資料庫伺服器。它允許你訪問線上字典。但是等一下,我們不是要離線使用嗎?這是為什麼我們要將其安裝到本地的原因。它帶有一個命令列用戶端。

要在Ubuntu或者Debian上安裝你要輸入:

  1. $ sudo apt-get install dictd 

這個很簡單。現在你需要安裝用的字典。安裝完每個字典外掛程式後dictd都會自動重新載入它的資料庫。讓我們來安裝英語字典和英語同義字詞典。

輸入:

  1. $ sudo apt-get install dict-gcide 
  2. $ sudo apt-get  install dict-moby-thesaurus 

如果你希望查詢其他可以查詢的語言,你可以輸入:

  1. $ sudo apt-cache search “dict package” 

這會列出下面這樣的:

  1. dict-freedict-eng-ara - Dict package for English-Arabic Freedict dictionary 
  2. dict-freedict-eng-cro - Dict package for English-Croatian Freedict dictionary 
  3. dict-freedict-eng-cze - Dict package for English-Czech Freedict dictionary 
  4. dict-freedict-eng-deu - Dict package for English-German Freedict dictionary 
  5. dict-freedict-eng-fra - Dict package for English-French Freedict dictionary 

現在你已成功安裝dictd了,之後你就可以尋找字典了。

首先,讓我們檢查一下dictd服務是否在運行並且安裝了什麼資料庫:

  1. $ dict -I 

樣本輸出:

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

為了查詢一個單詞,你可以指定要查詢的字典。讓我們查詢一下English one字典gcid):

  1. $ dict -d gcide [你要查的單詞] 

如果你不使用-d 參數,dictd會搜尋所有的安裝字典並返回匹配的結果。

via: http://www.unixmen.com/look-dictionary-definitions-via-terminal/

譯者:geekpi 校對:wxy

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.