ispell Command in Linux

Introduction to Ispell: A Command-Line Spell Checker

This lab provides a practical guide to using the ispell command-line spell checker on an Ubuntu 22.04 system. We will cover the installation process of the ispell package and demonstrate how to utilize it for spell-checking individual words and entire text files. The ispell command is a valuable tool for system administrators and anyone needing to proofread and edit text documents efficiently. This tutorial offers step-by-step examples to get you started with ispell.

Installing Ispell on Ubuntu 22.04

This section details the installation of the ispell command-line spell checker on an Ubuntu 22.04 system, often performed within a Docker container for isolation.

First, update your system's package index using apt-get:

sudo apt-get update

Example output:

Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [114 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [99.8 kB]
Fetched 324 kB in 1s (324 kB/s)
Reading package lists... Done

Next, install the ispell package itself:

sudo apt update
sudo apt-get install -y ispell

Example output:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libaspell15 libhunspell-1.7-0 liblcms2-2 libmpc3 libmpfr6 libpaper-utils libpaper1
Suggested packages:
  aspell-en hunspell-en-us
The following NEW packages will be installed:
  ispell libaspell15 libhunspell-1.7-0 liblcms2-2 libmpc3 libmpfr6 libpaper-utils libpaper1
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,519 kB of archives.
After this operation, 5,557 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu jammy/main amd64 libpaper1 amd64 1.1.28 [13.1 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy/main amd64 libpaper-utils amd64 1.1.28 [9,012 B]
Get:3 http://archive.ubuntu.com/ubuntu jammy/main amd64 libmpc3 amd64 1.2.1-1 [51.0 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy/main amd64 libmpfr6 amd64 4.1.0-3 [289 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy/main amd64 liblcms2-2 amd64 2.12-2 [168 kB]
Get:6 http://archive.ubuntu.com/ubuntu jammy/main amd64 libhunspell-1.7-0 amd64 1.7.0-3 [375 kB]
Get:7 http://archive.ubuntu.com/ubuntu jammy/main amd64 libaspell15 amd64 0.60.8-3 [575 kB]
Get:8 http://archive.ubuntu.com/ubuntu jammy/main amd64 ispell amd64 3.4.00-8 [37.0 kB]
Fetched 1,519 kB in 1s (1,519 kB/s)
Selecting previously unselected package libpaper1.
(Reading database ... 16100 files and directories currently installed.)
Preparing to unpack .../libpaper1_1.1.28_amd64.deb ...
Unpacking libpaper1 (1.1.28) ...
Selecting previously unselected package libpaper-utils.
Preparing to unpack .../libpaper-utils_1.1.28_amd64.deb ...
Unpacking libpaper-utils (1.1.28) ...
Selecting previously unselected package libmpc3:amd64.
Preparing to unpack .../libmpc3_1.2.1-1_amd64.deb ...
Unpacking libmpc3:amd64 (1.2.1-1) ...
Selecting previously unselected package libmpfr6:amd64.
Preparing to unpack .../libmpfr6_4.1.0-3_amd64.deb ...
Unpacking libmpfr6:amd64 (4.1.0-3) ...
Selecting previously unselected package liblcms2-2:amd64.
Preparing to unpack .../liblcms2-2_2.12-2_amd64.deb ...
Unpacking liblcms2-2:amd64 (2.12-2) ...
Selecting previously unselected package libhunspell-1.7-0:amd64.
Preparing to unpack .../libhunspell-1.7-0_1.7.0-3_amd64.deb ...
Unpacking libhunspell-1.7-0:amd64 (1.7.0-3) ...
Selecting previously unselected package libaspell15.
Preparing to unpack .../libaspell15_0.60.8-3_amd64.deb ...
Unpacking libaspell15 (0.60.8-3) ...
Selecting previously unselected package ispell.
Preparing to unpack .../ispell_3.4.00-8_amd64.deb ...
Unpacking ispell (3.4.00-8) ...
Setting up libpaper1 (1.1.28) ...
Setting up libpaper-utils (1.1.28) ...
Setting up libmpc3:amd64 (1.2.1-1) ...
Setting up libmpfr6:amd64 (4.1.0-3) ...
Setting up liblcms2-2:amd64 (2.12-2) ...
Setting up libhunspell-1.7-0:amd64 (1.7.0-3) ...
Setting up libaspell15 (0.60.8-3) ...
Setting up ispell (3.4.00-8) ...
Processing triggers for libc-bin (2.35-0ubuntu3) ...
Processing triggers for man-db (2.10.2-1) ...

With these steps completed, the ispell package is successfully installed and ready for use on your Ubuntu 22.04 system.

Using Ispell to Check the Spelling of Individual Words

This section demonstrates how to utilize ispell to verify the spelling of a single word.

Begin by creating a text file named word.txt within the ~/project directory, containing a misspelled word:

echo "wrod" > ~/project/word.txt

Now, use the ispell command to check the spelling of the word in the word.txt file:

ispell ~/project/word.txt

Example output:

wrod, line 1: Unknown word
& wrod, 1 suggestion: word
i

The output indicates that "wrod" is an unknown word, and ispell provides the suggestion "word" as the correct spelling.

To accept the suggested correction from ispell, type "i" and press Enter.

Using Ispell to Check the Spelling of a Text File

This section explains how to use ispell to spell-check an entire text file.

First, create a file named text.txt in the ~/project directory, populated with text containing several misspelled words:

cat > ~/project/text.txt << EOF
This is a test file with som misspelled words.
The quick brown fox jumps over the laxy dog.
EOF

Now, invoke the ispell command to check the spelling of the words in the text.txt file:

ispell ~/project/text.txt

Example output:

text.txt, line 1: som, misspelled
& som, 1 suggestion: some
i
text.txt, line 2: laxy, misspelled
& laxy, 1 suggestion: lazy
i

The output identifies "som" and "laxy" as misspelled words, offering "some" and "lazy" as suggestions. To accept these corrections, type "i" and press Enter for each word.

Conclusion: Mastering Command-Line Spell Checking with Ispell

This lab successfully guided you through the installation of the ispell command-line spell checker on an Ubuntu 22.04 system, typically within a Docker container. You learned how to update the package index and install the ispell package using apt-get. Furthermore, you gained practical experience in using ispell to check the spelling of both single words and complete text files. This knowledge is invaluable for systemadmin tasks, proofreading, and ensuring the accuracy of written documents within a Linux environment or when working as a root user.

400+ Linux Commands