Dictionary Script


The website provides a pretty good web interface for looking up English words and returning results from a multitude of well-known English dictionaries. In writing and editing, I need to use this service often, and quickly, so I find the web interface a bit limiting. So I wrote the following Unix shell script lu which can be used to easily look up words on from a Unix command prompt.


  • a Unix platform of some sort
  • an internet connection
  • the text-based browser lynx
  • your choice of pager such as more or less
  • the ability to place the following script in an executable file somewhere in your command path (try $HOME/bin/)

The Script

Type the following into a text file, call it lu, and make it executable (type chmod +x lu).


lynx -dump -nolist -pseudo_inlines                \
  ''$1'&r=67'  \
  | tail -n +13 | less -r

The key intelligence to this entire shell script is the lynx -dump switch, which translates the HTML commands into plain text and sends it to the standard output. See the lynx man page for details on the behaviour of the other switches. The variable $1 tells the shell to insert the word which is entered on the command line, the tail command chops off the uninteresting bits at the top of the output, and less gives you one screenful at a time.


Looks simple, does it? Well it is. And so is the usage. Type the following from your command prompt to look up the word “word”.

$ lu word

And you should get the following output.

8 entries found for word.


word   Pronunciation Key  (wûrd)
 1. A sound or a combination of sounds, or its representation in
    writing or printing, that symbolizes and communicates a meaning
    and may consist of a single morpheme or of a combination of
 2. Something said; an utterance, remark, or comment: May I say a word
    about that?
 3. Computer Science. A set of bits constituting the smallest unit of
    addressable memory.


Note that non-ASCII characters, such as the phonetic symbols, are sent directly to the terminal. If your terminal cannot handle such characters, then remove the -r flag from the less command above. Omitting this flag will display the characters as <FB> in reverse video. In a properly configured web-browser, the above should be display as “wûrd”.

For a brief tutorial on writing shell scripts, see the Answerman Article “How do I write a Shell Script?” at Dæ