0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

linuxのコマンドラインで使えるオフライン辞書を作った

Posted at

前々からlinuxで使えるオフラインの辞書がほしいと思っていた。単純に単語を入力すると意味が帰ってくる機能があればよいので、自作することにした。辞書データは下記のサイトのものを利用させてもらった。

無料 英和辞書データ ダウンロード
https://kujirahand.com/web-tools/EJDictFreeDL.php

辞書のデータは.txt形式とする。
将来的には他にも辞書データを追加して串刺し検索できるようにした。具体的な作業手順は以下のとおりである。なお、辞書データは./Documents/dictData/に保存してあるとする。

辞書ファイルの保管ディレクトリを作成する。

$ sudo mkdir /usr/local/share/dict/

辞書ファイルを移動する。

$ sudo cp ./Documents/dictData/*.txt /usr/local/share/dict/

~/.bashrc に以下の行を追加する。

# search from some dictionries
function dict() {
    grep ^$1 /usr/local/share/dict/*.txt -A 0 -wi --color |
    sed 's/\/usr\/local\/share\/dict\///g' |
    grep $1 -A 1 -wi --color
}

.bashrcファイルを読み込む

$ source ~/.bashrc

これでTerminalで

$ dict 調べたい単語

と入力すると結果が標準出力される。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?