home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 29.1 The UNIX spell Command Chapter 29
Spell Checking, Word Counting, and Textual Analysis
Next: 29.3 How Do I Spell That Word?
 

29.2 Check Spelling Interactively with ispell

The original UNIX spell checking program, spell (29.1 ) , is fine for quick checks of spelling in a short document, but it makes you cry out for a real spelling checker, which not only shows you the misspelled words in context, but offers to change them for you.

ispell
ispell , a very useful program that's been ported to UNIX and enhanced over the years, does all this and more. Here's the basic usage.

Just as with spell , you spell check a document by giving ispell a filename. But there the similarities cease. ispell takes over your screen or window, printing two lines of context at the bottom of the screen. If your terminal can do reverse video, the offending word is highlighted. Several alternate possibilities are presented in the upper-left corner of the screen - any word in ispell 's dictionary that differs by only one letter, has a missing or extra letter, or transposed letters.

Faced with a highlighted word, you have eight choices:

SPACE

Press the spacebar to accept the current spelling.

A

Type A to accept the current spelling, now and for the rest of this input file.

I

Type I to accept the current spelling now and for the rest of this input file, and also instruct ispell to add the word to your private dictionary. By default, the private dictionary is the file .ispell_words in your home directory, but can be changed with the -p option or by setting the environment variable (6.1 ) WORDLIST to the name of some other file. If you work with computers, this option will come in handy, since we use so much jargon in this business! It makes a lot more sense to "teach" all those words to ispell than to keep being offered them for possible correction. (One gotcha: when specifying an alternate file, you must use an absolute pathname (1.19 ) or ispell will look for the file in your home directory.)

0-9

Type the digit corresponding to one of ispell 's alternative suggestions to use that spelling instead. For example, if you've typed "hnadle," as I did when writing this article, ispell will offer 0: handle in the upper-left corner of your screen. Typing 0 makes the change and moves on to the next misspelling, if any.

R

Type R if none of ispell 's offerings do the trick, and you want to be prompted for a replacement. Type in the new word, and the replacement is made.

L

Type L if ispell didn't make any helpful suggestions, and you're at a loss how to spell the word correctly. ispell will prompt you for a lookup string. You can use * as a wildcard character (it appears to substitute for zero or one characters); ispell will print a list of matching words from its dictionary.

Q

Type Q to quit, writing any changes made so far, but ignoring any misspellings later in the input file.

X

Type X to quit without writing any changes.

But that's not all! ispell also saves a copy of your original file with a .bak extension, just in case you regret any of your changes. (This is starting to sound like a Ginsu knife commercial!) If you don't want ispell making .bak files, invoke it with the -x option.

How about this: ispell knows about capitalization. It already knows about proper names and a lot of common acronyms - it can even handle words like "TeX" that have oddball capitalization. Speaking of TeX (43.12 ) , it even has a special mode in which it recognizes TeX constructions. (Too bad ispell doesn't know about troff (43.13 ) .)

For even more features, see the manual pages stored with the program on the disc.

- TOR


Previous: 29.1 The UNIX spell Command UNIX Power Tools Next: 29.3 How Do I Spell That Word?
29.1 The UNIX spell Command Book Index 29.3 How Do I Spell That Word?

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System