Science and technology

How to examine spelling on the Linux command line with Aspell

Proper spelling does not appear to be crucial to many individuals nowadays. There are, nevertheless, these of us for whom it’s. Yes, I am a kind of folks.

While I am not a spelling cop, misspelled phrases stick out after I encounter them. They damage my eyes. They damage my mind. Any good textual content editor or phrase processor packs a spelling checker. If you are working in plain textual content, you possibly can go one other path to examine spelling: on the command line with a nifty utility referred to as GNU Aspell (which I will be calling Aspell from right here on in).

Aspell is quick, simple to make use of, and versatile. Let’s check out how one can use it.

Getting going

First, ensure you have Aspell put in in your system. It’s commonplace package with most Linux distributions. To discover out if Aspell is put in, open a terminal window and kind which aspell. That command ought to return one thing like /usr/bin/aspell. If it returns nothing, you possibly can set up Aspell utilizing your distro’s package deal supervisor, or you possibly can download and install it.

So you will have a textual content file that you just need to spell examine on the command line. Crack open a terminal window and navigate to the listing containing the textual content file you need to spell examine. Then, run the next command:

aspell examine file.txt

Aspell opens the textual content file in a two-pane interactive editor:

The high pane exhibits the file, with any errors (or perceived errors) highlighted. The backside lists the instructed corrections (primarily based on Aspell’s default dictionary) and numerous instructions that you should utilize.

In the display screen seize above, Aspell has flagged the acronym “PDF” as an error and instructed a number of options. I can do the next:

  • Press the quantity on my keyboard subsequent to a substitute for exchange the misspelled phrase with one other one.
  • Press i to disregard that occasion of the perceived error, or press I to disregard all situations of the error.
  • Press a so as to add the phrase to Aspell’s dictionary.
  • Press r or R to exchange that occasion or all situations of the phrase with a brand new phrase.

Let’s have a look at the final merchandise in that listing a bit extra intently. Let’s say I take advantage of the phrase archiving quite a few instances in a file. And, being a constant particular person, I misspell the phrase as archving every time I take advantage of it. Aspell will level that out to me:

Instead of correcting the spelling of that phrase every time, I need to do it in a single fell swoop. So, I press R. Aspell prompts me for a substitute.

I kind the substitute after which press Enter. The deed is finished, and Aspell strikes to the subsequent mistake.

Using a few of Aspell’s choices

Like any command-line utility, Aspell has quite a few choices. You most likely will not use a lot of them, however listed here are two that I discover helpful.

First off, –dont-backup. When you end spell checking a file, Aspell saves a duplicate of the unique with the extension .bak—for instance, djvu_utilities.txt.bak. I do not like backup information littering my directories. By specifying the –dont-backup choice, Aspell does not save a duplicate.

Next, –mode=. Not each file I spell examine on the command line is straight textual content. Often, I will examine Markdown, LaTeX, or HTML information. When I run Aspell with no choices, it flags markup as spelling errors. So, as an alternative of filling my dictionary with markup, I can specify –mode=tex or –mode=html. If you need a full listing of the modes you should utilize, kind aspell dump modes.

This is much from an exhaustive have a look at Aspell and its capabilities. If you are actually inquisitive about evrything it could possibly do, take a look at the manual.

Most Popular

To Top