[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Commands Reference, Volume 5

spell Command


Finds English Language spelling errors.


spell [ -b ] [ -i ] [ -l ] [ -v ] [ -x ] [ -d HashList ] [ -h HistoryList ] [ -s HashStop ] [ + WordList ] [ File ... ]


The spell command reads words in the file indicated by the File variable and compares them to those in a spelling list. Words that cannot be matched in the spelling list or derived from words in the spelling list (by applying certain inflections, prefixes, and suffixes) are written to standard output. If no file name is specified, the spell command reads standard input.

The spell command ignores the same troff, tbl, and eqn codes as does the deroff command.

The coverage of the spelling list is uneven. You should create your own dictionary of special words used in your files. Your dictionary is a file containing a sorted list of words, one per line. To create your dictionary, use the spellin command.

Files containing an alternate spelling list, history list, and stop list can be specified by file name parameters following the -d, -f, and -h flags. Copies of all output can be accumulated in the history file.

Three programs help maintain and check the hash lists used by the spell command:

/usr/lbin/spell/hashmake Reads a list of words from standard input and writes the corresponding 9-digit hash code to standard output.
/usr/bin/spellin Number Reads the specified Number of hash codes from standard input and writes a compressed spelling list to standard output.
/usr/lbin/spell/hashcheck SpellingList Reads a compressed SpellingList, recreates the 9-digit hash codes for all the words in it, and writes these codes to standard output.

The File parameter specifies the files that the spell command reads and compares them with the spelling list. If no file is specified, the command reads standard input.


-b Checks British spelling. However, this flag does not provide a reasonable prototype for British spelling. The algorithms to derive a match against the spelling dictionary by applying certain inflections, prefixes, and suffixes are based on American English spelling.
-d HashList Specifies the HashList file as the alternative spelling list. The default is /usr/share/dict/hlist[ab].
-h HistoryList Specifies the HistoryList file as the alternative history list, which is used to accumulate all output. The default is /usr/lbin/spell/spellhist.

Note: The HistoryList file must be an existing file with read and write permissions.
-i Suppresses processing of include files.
-l Follows the chain of all include files (.so and .nx formatting commands). Without this flag, the spell command follows chains of all include files except for those beginning with /usr/lib.
-s HashStop Specifies the HashStop file as the alternative stop list, which is used to filter out misspellings that would otherwise pass. The default is /usr/share/dict/hstop.
-v Displays all words not in the spelling list and indicates possible derivations from the words.
-x Displays every possible word stem with an = (equal sign).
+ WordList Checks WordList for additional word spellings. WordList is the name of a file you provide that contains a sorted list of words, one per line. With this flag, you can specify a set of correctly spelled words (in addition to the spell command's own spelling list) for each job.

Exit Status

The following exit values are returned:

0 Indicates successful completion.
>0 Indicates an error occurred.


  1. To check your spelling, enter:

    spell chap1 >mistakes

    This creates a file named mistakes containing all the words found in chap1 that are not in the system spelling dictionary. Some of these may be correctly spelled words that the spell command does not recognize. Save the output of the spell command in a file because the word list may be long.

  2. To check British spelling, enter:
    spell -b chap1 >mistakes
    This checks chap1 against the British dictionary and writes the questionable words in the mistakes file.
  3. To see how the spell command derives words, enter:
    spell -v chap1 >deriv
    This lists words not found literally in the dictionary but are derived from forms of dictionary words. The prefixes and suffixes used to form the derivations are indicated for each word. Words that are not in the dictionary at all are also listed.
  4. To check your spelling against an additional word list, enter:
    spell +newwords chap1
    This checks the spelling of words in chap1 against the system dictionary and against newwords. The newwords file lists words in alphabetical order, one per line. You can create this file with a text editor, such as the ed editor, and alphabetize it with the sort command.


/usr/share/dict/hlist[ab] Contains hashed spelling lists, both American and British.
/usr/share/dict/hstop Contains a hashed stop list.
/usr/lbin/spell/spellhist Contains a history file.
/usr/lbin/spell/compress Contains an executable shell program to compress the history file.
/usr/lbin/spell/hashmake Creates hash codes from a spelling list.
/usr/bin/spellin Number Creates spelling list from hash codes.
/usr/lbin/spell/hashcheck SpellingList Creates hash codes from a compressed spelling list.
/usr/lbin/spell/spellinprg Main program called by the spellin file.
/usr/lbin/spell/spellprog Checks spelling.

Related Information

The deroff command, eqn command, neqn command, sed command, sort command, spellin command, spellout command, tbl command, tee command, and troff command.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]