A command-line dictionary tool
Wordsmith
![© Photo by Joshua Hoehne on Unsplash © Photo by Joshua Hoehne on Unsplash](/var/linux_magazin/storage/images/issues/2023/270/dict/photobyjoshuahoehneonunsplash_dictionary.png/820539-1-eng-US/PhotobyJoshuaHoehneonUnsplash_dictionary.png_medium.png)
© Photo by Joshua Hoehne on Unsplash
With the dict client, you can quickly search dozens of natural language dictionary databases for the perfect word.
As a writer, I rarely need to look up the definition of a word. If I don't know a word, I'm not going to risk using it. However, I frequently check that a word has the exact nuance I want. If it does not, I turn to a thesaurus to search for a closer alternative. Unfortunately, a regular dictionary is next to useless for these purposes. That is why I was pleased to discover dict
[1], which not only has the information needed for such purposes, but runs from the command line for added efficiency.
A client for the DICT [2] dictionary network protocol, dict
essentially searches several dozen databases and returns comprehensive results in seconds. It is available for major distributions, but note that each database is often in a separate package in distro repositories and must be installed separately from the basic command. The option --dbs
(-D
) will show a list of these databases, as will the web version [3] of dict
(Figure 1). The databases supported by dict
include a number of dictionaries, a thesaurus, a collection of acronyms, the Jargon File, the CIA World Factbook, and 34 other languages besides English – far more than the average dictionary offers. The results include not only the range of literal meanings, but numerous contexts as well. Some default results for the word "red" from my current installation are shown in Table 1.
Table 1
Sample Results
Basic definitions: |
Red \Red\, v. t. To put on order; to make tidy; also, to free from entanglement or embarrassment; – generally with up; as, to red up a house. [Prov. Eng. & Scot.] |
Notes on how to use the word: |
Red is often used in the formation of self-explaining compounds; as, red-breasted, red-cheeked, red-faced, red-haired, red-headed, red-skinned, red-tailed, red-topped, red-whiskered, red-coasted. |
Contexts: |
{Red admiral} (Zool.), a beautiful butterfly ({Vanessa Atalanta}) common in both Europe and America. The front wings are crossed by a broad orange red band. The larva feeds on nettles. Called also {Atalanta butterfly}, and {nettle butterfly}. |
Note: |
Etymologies, synonyms, and translations may also be given, depending on the databases installed. |
This amount of information makes for intensive scrolling, so dict
used with only the basic command and a search term should usually be used with a pager like less
or cat
. Another option is to specify a specific database so that only the relevant results are given, using the option --database
(-d
) DATABASE
. For instance
dict -d moby-thesaurus red
will return only synonyms (Figure 2). Similarly, if you wanted to look up the Old Testament character Jezebel, you could specify easton
to get results only from Easton's Bible Dictionary (1897) (Figure 3) – an encyclopedia entry, rather than a dictionary definition.
Another alternative for limiting results is to choose a strategy from those displayed using the options with --strats
(-S
). These strategies are analogous to regular expressions, but actually include both basic and modern options (Figure 4). These strategies are not documented, but most are self-explanatory if sometimes a bit obscure. For example, you can specify the prefix, suffix, and substrings to find a family of related words and use soundex
to search for similar sounds, which might be useful in a rhymed poem. However, before you choose a limiting strategy, you can use --match
(-m
) to see how many results a search will return.
If a search is not useful, you can trying working more closely with a database. With --serverinfo
(-I
) and --serverhelp
(-H
), you can see more information about a database's server. Alternatively, --info DATABASE
(-i
) displays information about the database itself. However, note that no information may be available for some databases, in which case dict
returns the misleading message, invalid database
.
Depending on your preferences or how you plan to use search results, you can also use --format
(-f
) FORMAT
. Four different formats are available, as described in the man page: I
, S
, D
, and m
. Annoyingly, these formats are diagrammed but not documented, so you may have to do more than one test before finding the one you prefer.
Limitations
Linux has other dictionary tools besides dict
. On the desktop, you can choose such applications as GoldenDict, Artha, the WordNet browser, and Gnome Dictionary. However, so far as I can determine, dict
is the only one available from the command line and by far the most flexible and thorough. In fact, its potential is so great that its lack of documentation and examples is irksome, if often surmountable. It is not clear whether dict
is still being actively developed. Still, with patience, what is available is so useful that no writer on Linux should be without it.
Infos
- dict: https://man.archlinux.org/man/dict.1.en
- DICT dictionary network protocol: https://en.wikipedia.org/wiki/DICT
- dict web version: http://dict.org/bin/Dict
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.
-
SUSE Offers CentOS 7 Support with Liberty Linux Lite
SUSE's Liberty Linux support offering now includes CentOS 7, which means businesses won't be forced to migrate those servers for some time.
-
Ubuntu's App Center Finally Supports Local Installs Again
If you regularly download .deb files and would prefer a GUI method of installing, Ubuntu has your back.
-
AlmaLinux Now Supports Raspberry Pi 5
If you're looking to create with the Raspberry Pi 5 and want to use AlmaLinux as your OS, you're in luck because it's now possible.
-
Kubuntu Focus Releases New Iterations of Ir14 and Ir16 Laptops
If you're a fan of the Kubuntu Focus laptops or have been waiting for the right time to purchase one, that time might be now.
-
NixOS 24.05 Is Ready for Prime Time
The latest release of NixOS (Uakari) has arrived and offers its usual reproducible, declarative, and reliable goodness.
-
Linux Lite 7.0 Officially Released
Based on Ubuntu 24.04 and kernel 6.8, Linux Lite version 7 now offers more options than ever.
-
KaOS Linux 2024.05 Adds Bcachfs Support and More
With updates all around, KaOS Linux now includes support for the bcachefs file system.
-
TUXEDO Computers Unveils New Iteration of the Stellaris Laptop Line
The Stellaris Slim 15 is the 6th generation and includes either an AMD or Intel CPU