Ever wanted to spell check text files directly from the Linux command line? This article will get your setup and started with Aspell, the interactive spell checker. Start spell checking your text files, for free, today!
What Is Aspell?
GNU Aspell is an open source and free spell checker which can be installed easily on your Linux system. You can use it at the command line, and with a few option tweaks one can check text files reliably and quickly. This article was spell checked with Aspell at the command line, as well as spellintian which is another utility you may like to explore.
To install Aspell on your Debian/Apt based Linux distribution (Like Ubuntu and Mint), execute the following command in your terminal:
sudo apt install aspell
If the above command does not automatically install aspell-en on your system as well, please add it to the command line.
To install Aspell on your RedHat/Yum based Linux distribution (Like RHEL, Centos and Fedora), execute the following command in your terminal:
sudo yum install aspell
Let’s spell check!
Let’s create a file with a variety of spelling errors:
We can now check this file with Aspell:
aspell --master=en_US --lang=en_US -c test_spelling.txt
-c option will spell check a single file, and the
--lang settings point Aspell to using a single specified directory, or terminate in case this is not possible. Here we use the en_US dictionary to use the US English language.
Another option which I personally use regularly, and it is so new it has not been added to the manual yet, is
--mode=markdown, which makes Aspell aware of the fact that one is using markdown based text. This may help with avoiding false positives.
For additional options, language settings, and different modes, you can reference the Aspell manual by using
man aspell at the command line. For English language abbreviations like en_US and en_GB, see the installation screenshot above as it highlights the ones installed.
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 have been using Aspell for quite some time, and have found it to be a highly reliable, fast, low-key, and easy-to-use spell checker. The personal dictionary feature (saved in the
.aspell.en.pws file in your home directory, i.e.
~/.aspell.en.pws) works exceedingly well.
Let’s check our file with spelling errors.
I simply press 1 to substitute ‘Thiz’ to the proposed ‘This’.
Slightly trickier, but option 3 is the way to go. A simple 3 keypress and we’re onto the next error found.
Pressing 4 and moving on…
The first option looks right. A simple 1 keypress.
All other words were all 1 keypresses also. And, thanks to Aspell, our file now contains a lie:
As all spelling mistakes are fixed!
By pressing a single key per mistake, we were able to fix all errors in this file. We could have also added a word if the dictionary was not aware of it (happens somewhat infrequently) by pressing
a, and we can press the
r key to type a new word ourselves to replace whatever mistake was found. If Aspell cannot find the new word we just typed, it will re-highlight it and we can correct it, add it, or replace it again.
As you can see, spell checking text based files at the Linux command line is easy and straightforward with the Aspell tool. Enjoy!
This post was written by Roel Van de Paar and was first posted to www.cloudsavvyit.com
Do you find this article helpful? Your Friend might too. So, please Share it with them using the Share button above.
Will you like to get notified when I post new updates? Then Follow me on any of my social media handles: Google News, Telegram, WhatsApp, Twitter, Facebook, Pinterest.
You can also drop your email address below if you wish to be notified by mail.