Spell check is a "feature" we all take for granted. No matter where we are typing - in a document, on a blog, in an email...we all know our spell check will be there to take care of us. But what do we do about those files that are not created or edited in tools without spell checkers? I don't know about you, but I create a lot of files in applications that have no spell check. For those files I invoke the power of aspell.
Aspell is an interactive, command-line spell checking tool. It's really easy to use, reliable, and flexible. You can even use aspell to generate word lists for tools like password cracking tools (and we'd only use those types of tools when we have lost our own passwords right!). In this article I will show you how install and use the command line tool aspell.
In most cases, aspell should be installed on your machine as it is used by a number of applications. In the event it is not, the installation is simple. Naturally, since aspell is a command-line tool, let's install it via the command line. This installation can be done with a single command like so:
sudo apt-get install aspell
The above is for Ubuntu and/or Debian-based distributions. If you are using a Fedora-like distribution (think rpm-based), you could install with the command:
yum install aspell
There may, or may not, be dependencies to install along with aspell which your installer should pick up.
That's it. You should now have a working copy of aspell installed.
The basic usage of aspell is as such:
aspell [options] <command> file
The above may seem a bit confusing, but remember, since aspell is used by numerous applications, it is a very powerful tool. That power can be simplified very easily. Let's first take a look at how aspell can be used to spell check a file. Say you have a file, my_file.txt, that you need checked. From the command line you could issue:
aspell -c my_file.txt
For example's sake I copied text from a recent article I wrote and named it my_file.txt. When I run aspell against that file it looks like what you see in Figure 1. As you can see, what aspell will do is step through the file, word by word, and check the spelling. When aspell comes across a word it thinks is incorrect you get a list of possible solutions that you can choose from. Choose your solution and aspell will move on to the next word. It's really quite simple.
Use the aspell dictionary
Aspell can be used in many ways. One very interesting way is to take advantage of the included dictionary. Let's say you need to generate an alphabetized word list (I had to do this recently to try to crack a forgotten password for a client - it was completely legit). To do this I took advantage of aspell's dictionary like so:
Download the specific aspell dictionary I needed from here.
Unpack the dictionary with the commands bunzip2 aspell-XXX.tar.bz2 and tar xvf aspell-XXX.tar (Where XXX is the release number).
Now you will have a word list, containing a single word per line, thanks to the aspell dictionaries. Pretty cool.
Aspell is a very powerful tool. But don't think that its only use is for external applications. Because this is Linux, you can also take advantage of the tools that other tools take advantage of. If you need more information on aspell (and all of it's options and commands - there are a LOT of them), issue the command man aspell to find out more.
If you like our content, and would like to help, please consider making a contribution: