lookというコマンドがあります。
たとえば、impeachmentという英語の綴りを忘れてしまった時に、
look impeaと入力すると、以下のようにimpeaから始まる英単語がすべて表示されます。
$ look impea impeach impeached impeaches impeaching impeachment impeachment's impeachments
ん〜。impeaから始まる単語がわかったところで、このコマンドの良さが見い出せません。
日本人の私にとって、英単語の綴りがわからなくなる場合は、まずimpleaから思い出せない気がするからです。
lookコマンドの書式は、
look [-dfa] [-t termchar] 文字列 [ファイル]
それぞれのオプションの意味です。
-d 辞書で使用されているアルファベットと数字だけを比較対象とする
-f アルファベットの大文字、小文字を区別しない
-a 別の辞書 /usr/share/dict/web2 を使用する
-t 文字列の終端文字を指定する
ファイルに何も指定しないと
/usr/share/dict/words
が指定されたことと同一になります。
look impea
は、
grep ^impea /usr/share/dict/words
と結果は同じです。
比べてみましょう
$ look impea | cat -n 1 impeach 2 impeached 3 impeaches 4 impeaching 5 impeachment 6 impeachment's 7 impeachments $ grep ^impea /usr/share/dict/words | cat -n 1 impeach 2 impeached 3 impeaches 4 impeaching 5 impeachment 6 impeachment's 7 impeachments
結果は同じでした。
grepと同じことができるようです。
lookのメリットとは……。
You always do the right thing. God Bless you.
Thank you
Good post! I read your blog often and you always post excellent content. I posted this article on Facebook and my followers like it. Thanks for writing this!
whoa1h this blog is great i love reading your posts. Keep up the great work! You know, a lot of people are looking around for this information, you can aid them greatly.