Linux ispell command
The Linux ispell command is used as a spell-checking program.
By default, ispell uses the /usr/lib/ispell/english.hash dictionary file to check text files. If it finds a word that is not in the dictionary, ispell suggests alternatives or lets you add the new word to your personal dictionary.
Syntax
ispell [-aAbBClmMnNPStVx][-d<字典文件>][-L<行数>][-p<字典文件>][-w<非字母字符>][-W<字符串长度>][要检查的文件]
Parameters:
- -a This parameter must be used when the output of another program is sent to ispell.
- -A When the string "&Include File&" is encountered, check the contents of the file specified after the string.
- -b Create a backup file named .bak.
- -B Check for hyphenation errors.
- -C Do not check for hyphenation errors.
- -d
Specify the dictionary file. - -l Read strings from standard input and display misspelled words when finished.
- -L
Specify the number of lines of context to display. - -m Automatically take word-ending variations into account.
- -M After entering ispell, display the command keys at the bottom of the screen.
- -n The file to check is in noff or troff format.
- -N After entering ispell, do not display the command keys at the bottom of the screen.
- -p
Specify the personal dictionary file. - -P Do not take word-ending variations into account.
- -S Do not sort the suggested replacement words.
- -t The file to check is in TeX or LaTeX format.
- -V Non-ANSI standard characters are displayed in the form "M-^".
- -w
When checking, specifically pick out words containing the specified characters. - -W
Do not check words of the specified length. - -x Do not create a backup file.
Example
To check the spelling of a file, for example the file testfile, you can use the following command:
ispell testfile
If suspicious words appear in the file, the first one is highlighted, and suggestions for corrections along with ispell's operation commands are given at the bottom of the screen, as shown below:
netwrks File: testfile
Linux netwrks are becoming more and more common, but security is often an overlooked
issue. Unfortunately
0: networks
[SP] R)epl A)ccept I)nsert L)ookup U)ncap Q)uit e(X)it or ? for help
In this example, the misspelling "netwrks" is detected and a correction is suggested; entering "0" at this point uses "networks" to correct the error and continues to the next error until all errors have been shown.
From the example above we can see that the file testfile contains spelling errors and needs to be backed up after modification. Use the following command:
ispell-b testfile #检查拼写错误的同时,备份文件
If the file no longer has spelling errors, nothing is displayed, and the ls command shows that a backup file testfile.bak has been created in the current directory. The result is shown below:
$ ls #以列表的形式查看当前目录下的文件
examples.desktop testfile_1 testfile.bak xx01 模板图片 音乐
testfile testfile1 testfile_2 xx00 公共的视频文档桌面
Here, testfile.bak is the backup file just created by the command, and its content is the same as the original testfile.
Linux Command Reference