Linux aspell Command Tutorial for Beginners (5 Examples)

Linux aspell Command Tutorial for Beginners (5 Examples)

A spell checker is an important tool if your work involves writing or editing text files or documents. While most GUI based editors come with spell checking feature inbuilt, the same cannot be said for command line editors. However, there are separate command line tools that can help you with spell check.

Here, in this tutorial, we will discuss one such utility, dubbed aspell. But before we dive in, it’s worth mentioning that all examples in the article have been tested on an Ubuntu 18.04 LTS machine.

Linux aspell command

As already mentioned in the beginning, the aspell command lets you perform spell check on a text file. You can even check for individual words as well. Following is its syntax:

aspell [options] <command>

And here’s what the man page says about this tool: aspell is a utility program that connects to the Aspell library so that
       it can function as an ispell -a replacement, as  an  independent  spell
       checker,  as a test utility to test out Aspell library features, and as
       a utility for managing dictionaries used by the library.

       The Aspell library contains an interface allowing other programs direct
       access  to  its  functions  and  therefore reducing the complex task of
       spell checking to simple library calls.  The default library  does  not
       contain  dictionary  word  lists.  To add language dictionaries, please
       check your distro first for modified dictionaries, otherwise look  here
       for base language dictionaries <http://aspell.net>.

Following are some Q&A-styled examples that should give you a better idea on how the utility works.

Q1. How to use the aspell command?

The basic usage of aspell isn’t completely straight forward, so it’s good to get a usage summary, something which you can get using the ‘usage’ command option.aspell usage

And here’s what you’ll likely get in output:Usage: aspell [options] <command>
<command> is one of:
  -?|usage         display a brief usage message
  help             display a detailed help message
  -c|check <file>  to check a file
  -a|pipe          "ispell -a" compatibility mode
  [dump] config    dumps the current configuration to stdout
  config <key>     prints the current value of an option
  [dump] dicts | filters | modes
    lists available dictionaries / filters / filter modes
[options] is any of the following:
  --encoding=<str>            encoding to expect data to be in
  --mode=<str>                filter mode
  -l,--lang=<str>             language code
  -d,--master=<str>           base name of the main dictionary to use
  --sug-mode=<str>            suggestion mode

Q2. How to check a file for spelling errors with aspell?

This can be done using the -c command line option. For example:aspell -c test.txt

Following is what the tool displayed upon executing the above command:

So you can see the tool highlighted the first spelling mistake in the text, and in the lower half of the window, offered options that it thought I’d be interested in as replacement. Also, if you see closely, there are also options to ignore the currently highlighted spelling mistake, replace all occurances of the word currently highlighted, add to aspell’s dictionary, and exit from this view.

Q3. How to use aspell to check individual words?

This you can do using the -a command line option.aspell -a

As soon as you run this command, it will wait for user input. Type a word in this mode, press enter, and you’ll see aspell offering spelling suggestions on stdout.

The following screenshot shows this command line option in action:

Q4. How to use aspell to check words in bulk?

This you can do using the ‘list’ command option.aspell list

The above command, when run, will wait for user input. Add as many words as you want, and when done, press Ctrl+D. Then you’ll see that aspell will display incorrectly spelled words below the input you provided.

Following screenshot shows this option in action:

Q5. How to control dictionary used by aspell?

The man page for aspell offers various options that you can use to control the dictionary used by this command. Here are some of the important ones: --master=<name>, -d <name>
              Base name of the dictionary to use.  If this option is specified
              then Aspell will either use this dictionary or die.

              Location of the main dictionary word list.

       --lang=<string>, -l <string>
              Language to use.  It follows the same format of the  LANG  envi?
              ronmental variable on most systems.  It consists of the two let?
              ter ISO 639 language code and an optional two  letter  ISO  3166
              country  code  after a dash or underscore.  The default value is
              based on the value of the LC_MESSAGES locale.

              The preferred size of the dictionary word list.   This  consists
              of  a  two char digit code describing the size of the list, with
              typical values of: 10=tiny, 20=really small,  30=small,  40=med-
              small, 50=med, 60=med-large, 70=large, 80=huge, 90=insane.


You’ll likely agree that aspell is a useful tool that Linux command line users should be aware of. We’ve discussed the basics of this tool here. Once you have practiced these options, head to the command’s man page to learn more about it.

Đăng ký liền tay Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !

Add Comment

Click here to post a comment

Đăng ký liền tay
Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !