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


Unix Power ToolsUnix Power ToolsSearch this book

16.3. How Do I Spell That Word?

Are you writing a document and want to check the spelling of a word before you finish (if you aren't using a word processor with automatic spelling correction, that is)? A Unix system gives you several ways to do this.

NOTE: Because this is Unix, you can use any of these approaches when you write a script of your own.

  1. If you aren't sure which of two possible spellings is right, you can use the spell command with no arguments to find out. Type the name of the command, followed by a RETURN, then type the alternative spellings you are considering. Press CTRL-d (on a line by itself) to end the list. The spell command will echo back the word(s) in the list that it considers to be in error:

    $ spell
    misspelling
    mispelling
    CTRL-d
    mispelling
  2. If you're using ispell ( Section 16.2) or the newer aspell, you need to add the -a option. The purpose of this option is to let the speller interact with other programs; there are details in the programs' documentation. But, like most Unix filters, you can also let these programs read a word from standard input and write their response on standard output; it will either tell you that the spelling is right or give you a list of suggestions. aspell and ispell will use their local dictionaries and improved spelling rules.

    As an example, let's check the spelling of outragous and whut with both ispell and aspell:

    $ ispell -a
    @(#) International Ispell Version 3.1.20 10/10/95
    outragous whut
    & outragous 1 0: outrageous
    & whut 5 10: hut, shut, what, whet, whit
    
    CTRL-d
    $ aspell -a
    @(#) International Ispell Version 3.1.20 (but really Aspell .32.6 alpha)
    outragous whut
    & outragous 3 0: outrageous, outrages, outrage's
    & whut 5 10: what, whet, whit, hut, shut
    
    CTRL-d
    $

    When these spellers start, they print a version message and wait for input. I type the words I want to check and press RETURN. The speller returns one result line for each word:

    • A result of * means the word is spelled correctly.

    • A line starting with & means the speller has suggestions. Then it repeats the word, the number of suggestions it has for that word, the character position that the word had on the input line, and finally the suggestions.

    • So ispell suggested that outragous might be outrageous. aspell also came up with outrages and outrage's. (I'd say that outrage's is barely a word. Be careful with aspell's suggestions.) Both spellers had five suggestions for whut; the differences are interesting . . .

    • A result of # means there were no suggestions.

    After processing a line, the spellers both print an empty line. Press CTRL-d to end input.

  3. Another way to do the same thing is with look (Section 13.14). With just one argument, look searches the system word file, /usr/dict/words, for words starting with the characters in that one argument. That's a good way to check spelling or find a related word:

    % look help
    help
    helpful
    helpmate

    look uses its -df options automatically when it searches the word list. -d ignores any character that isn't a letter, number, space or tab; -f treats upper- and lowercase letters the same.

--JP and DD



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.