Sunday, October 14, 2007

Dictionary Lookup via Command Line


#curl dict://dict.org/d:YourWord
To help you remember, d: stands for DEFINE.

For example, to look up the word "bash", (all output in this article are greatly abbreviated for clarity)
# curl dict://dict.org/d:bash
151 "Bash" gcide "The Collaborative International Dictionary of English v.0.48"
Bash \Bash\, n.
1. a forceful blow, especially one that does damage to its
target.
[PJC]
2. a elaborate or lively social gathering or party.
[PJC]


The dict.org web site supports 77 dictionaries. To list them:
#curl dict://dict.org/show:db

So, if you want to know the computer meaning of "bash", specify foldoc "The Free On-line Dictionary of Computing" like this:
#curl dict://dict.org/d:bash:foldoc
151 "bash" foldoc "The Free On-line Dictionary of Computing (27 SEP 03)"
bash
Bourne Again SHell. {GNU}'s {command interpreter} for {Unix}.
Bash is a {Posix}-compatible {shell} with full {Bourne shell}
syntax, and some {C shell} commands built in. The Bourne
Again Shell supports {Emacs}-style command-line editing, job
control, functions, and on-line help. Written by Brian Fox of
{UCSB}.

To display results from all libraries, do this:
#curl dict://dict.org/d:bash:*


Fuzzy matching is also possible. Replace the "d" or Define command with "m" which stands for MATCH.
#curl dict://dict.org/m:bash

With the match command, you can also specify the strategy such as exact, prefix, suffix, or even soundex.

#curl dict://dict.org/m:bash::prefix
gcide "Bash"
gcide "Bashed"
gcide "Bashful"
gcide "bashful Billy"


To list all supported strategies:
#curl dict://dict.org/show:strat

8 comments:

Anonymous said...

Thanks for this.
It was really useful.

Anonymous said...

At least for me, dict.org is really slow (3000-9000ms ping time). What about other dictionaries with the dict:// protocol?

Anonymous said...

Found this site:
http://luetzschena-stahmeln.de/dictd/index.php

sreekumar said...

Thank you

Anonymous said...

Very helpful. Now I can do vocab homework without riffling through a real dictionary

Korey said...

Wow, what a helpful post! I write a lot in vim, so having a command line dictionary is extremely nice. Shortly after reading this post I discovered the "dict" program on Ubuntu, which is a command line dict client. This program allows you to type "dict elephant" to define elephant and that saves you a few keystrokes. It has options for specifying host, database, etc.

Raf@!! said...

What a useful post, I have been using Google dictionary from console with some scripts, but google dictionary is died, thanks for the info.

Anonymous said...

This is AWESOME!!! Thanks. Luv it!