CLI Magic: Ispell


Author: Joe Barr

Unless you are one of those who writes everything you write from inside one of those behemoth office-style word (or is it world?) processors, a fast, convenient, powerful, and stand-alone spell checker is a very hand thing to have around. Luckily for us in the Unix/Linux world, we’ve had one forever: it’s called Ispell. Climb down out of that rodent-driven environment you spend too much time in for awhile, and I’ll show you.

According to the International Ispell home page, R. E. Gorin chiseled the original out of PDP-10 assembler code in 1971. Pace Willison ported that version to C in the early 80s, and later in the decade it was adopted by Walt Buehring, who made it available on the Internet. The current version is maintained by Geoff Kuennig, who is also the guy who made it international. There is even a version for the Emacs afflicted, but we won’t go into that.

Using Ispell is as easy as typing the program name and the file to be checked at the command line, like this:

ispell which.txt

Assuming it finds some misspelled words, Ispell responds with a line showing the word in question, the file it is checking, the context the word is used in, and a list of options for how to proceed. The option line looks like this:

[SP] R)epl A)ccept I)nsert L)ookup U)ncap Q)uit e(X)it or ? for help

The space bar (shown on the line above as [SP]) tells Ispell to accept the spelling in this instance. That can be modified to indicate N instances. Or you can R)eplace, A)ccept (for the entire session), I)nsert, L)ookup, or Uncap the word. Quit, Exit and Help are also choices.

In the example Screen 1 shown below, I want to correct the term “newbies” to its proper spelling, “noobies.” So I type R to replace the term. Ispell prompts me for the new word, and does the replacement.

Screen 1
Screen 2

But since it doesn’t find “noobies” either, Ispell highlights it just as it did “noobies.” There is one difference, though. This time it offers to possible substitutions: boobies or loobies. To replace the term in question with a suggested term, simply enter the number preceding it. In this case, with a 0 or a 1.

If you select the Insert option, Ispell adds the term to its dictionary and won’t bother you about it again. If you’re writing geeky stuff with a lot of technical jargon or URLs, this can be a big timesaver.

If you’re uncertain whether or not you’re using the correct word, you can use the Lookup option. It shows all the words it knows that follow the pattern you enter. For example, if I ask it to Lookup “new*” (the asterisk is a wildcard), it responds as you see in the example Screen 2.

Note that you have two options for stopping Ispell. You can eX)it, which writes all the corrections so far to the file, or you can simply Q)uit and leave the file just as you found it.

If you’re writing for an online publication, like or NewsForge, your text may have a lot of HTML code embedded in it. You can instruct Ispell to bypass the tags by ignoring everything between the signs, by starting it with the -H option. Well, almost everything. It will still examine ALT tag entries.

Is that all there is?

In a word, no. There’s a lot more. The Ispell download includes a number of related helper programs, like buildhash, munchlist, findaffix, tryaffix, ijoin, and icombine.

Briefly, buildhash creates hashed dictionary files for later use by Ispell. Munchlist is a shell script to reduce the size of dictionary files, since personal dictionaries can grow to be quite large and impact Ispell performance.

For more information on Ispell, and all of its helper programs, I refer you to man ispell.