Ever wanted to spell check text files directly from the Linux command line? This article will help you set up and get started with Aspell, the interactive spell checker. Start checking the spelling of your text files today for free!
7;s A magic spell?
GNU Aspell is an open source and free spell checker that can be easily installed on your Linux system. You can use it on the command line, and with a few option tweaks, you can check text files reliably and quickly. This article has been checked on the command line with Aspell, as well spellintian which is another utility you may want to explore.
to install A magic spell
to install A magic spell on your Debian / Apt based Linux distribution (such as Ubuntu and Mint), run the following command in your terminal:
sudo apt install aspell
If the above command does not install automatically aspell-en on your system, then add it to the command line.
to install A magic spell on your RedHat / Yum based Linux distribution (such as RHEL, Centos and Fedora), run the following command in your terminal:
sudo yum install aspell
Let’s check spelling!
Let’s create a file with several spelling errors:
We can now check this file with Aspell:
aspell --master=en_US --lang=en_US -c test_spelling.txt
-c option will check the spelling of a single file, and the
--lang settings direct Aspell to use a single specified folder, or terminate if this is not possible. Here we use the en_US dictionary to use the American English language.
Another option that I personally use regularly that is so new that it has not been added to the manual yet is
--mode=markdown, which makes Aspell aware of the fact that text based on price cuts is used. This can help prevent false positives.
For additional options, language settings and different modes, please refer to the Aspell manual with
man aspell on the command line. For English abbreviations such as en_US and nl_GB, see the installation screenshot above, as it highlights the installed ones.
You may also need to install additional packages if you are interested in other languages. For example,
aspell-de can be installed for German support, etc.
Output and performance
I’ve been using Aspell for quite some time and have found it to be a very reliable, fast, low-key, and easy to use spell checker. The personal dictionary function (stored in the
.aspell.en.pws file in your home directory, ie
~/.aspell.en.pws) works extremely well.
Let’s check our file for spelling errors.
I just press 1 to replace ‘Thiz’ with the proposed ‘This’.
Slightly more difficult, but option 3 is the way to go. A simple one 3 keypress and we are at the following found error.
To press 4 and move on …
The first option looks good. A simple one 1 Press the button.
All other words were all 1 keystrokes too. And thanks to Aspell, our file now contains a lie:
Because all spelling mistakes have been fixed!
By pressing one key per error, we were able to fix all errors in this file. We could also have added a word if the dictionary didn’t know about it (uncommon) by pressing
a, and we can on the
r Press to type in a new word to replace the error found. If Aspell can’t find the new word we just typed, it will be highlighted again and we can correct, add, or replace it again.
As you can see, the spell checking of text-based files on the Linux command line is simple and straightforward with the Aspell tool. To enjoy!