DEV Community

Cover image for Spell Check on Your Linux Terminal
MINHCT
MINHCT

Posted on

Spell Check on Your Linux Terminal

Hi everyone, it’s me again. In this article, I will guide you guys on how to check spelling right into our Linux terminal. The advantage for this is that we don’t need the internet to use some online tools like Grammarly or google translate… Cool, right? So, let’s jump into it.

How to use spell check in Linux

Well in order to do this, we will use the package name aspell.

Aspell is an interactive spell checker which checks the spelling via standard input or by reading a specific file. Also, it can read and check spelling in markdown or HTML files too.

To check if your terminal is currently having aspell or not, run this command.

aspell --help

aspell help

If you encounter some error, then definitely you do not have it at the moment. Don’t worry, run this command to install it to your terminal.

sudo apt install aspell -Y

How To Use Aspell to Check the Spelling of Word one-by-one?

Super straightforward, all you need to do is pass this line of code to your terminal then type the word that need to be checked.

aspell -a

For example

spell check word

As you can see, when I type the wrong word helo, aspell automatically recommend for us all the correct word that related to helo. In this case, hello is the correct one.

How to Check the Spelling of a Word from a File

Simply execute this command

aspell -c [fileName]

For example, let spell check a file name index.txt.

aspell -c index.txt

The following screen will display to your terminal.

aspell

As you can see, each incorrect word will be highlighted by aspell, to correct that wrong word, simply press the number of word that we want to replace. Number 1 is the best choice for this usecase.

aspell

Note that the second incorrect word will be selected next, and you can do the same with the above example.

How to Check Spelling on Other Files?

Like I mentioned before, aspell can be used for other files such as HTML or markdown… All you need to do is execute this command line.

aspell check --mode=[mode_type] [file_name]

The supported modes are none, url, email, markdown, html, tex, texinfo, and nroff.

Let’s see a quick example of fixing the spelling mistakes on a markdown file.

aspell -c --mode=markdown spellcheck.md

aspell

🧡 Conclusion

And that all for this blog, if this was helpful to you, please leave me a like👋 and follow me 😘. That will help me a lot.

If you want more exciting content like this, then you can refer to my portfolio website or my Github for more detail 😎.

my logo

Top comments (1)

Collapse
 
divyanshukatiyar profile image
Divyanshu Katiyar

A really interesting article. I'm curious to know what the aspell runs on, maybe a python script. Moreover, would love to know if it uses some corpora of words or an algorithm to compare with the wrongly spelled words :)