Check Spelling from the Linux Command Line
I’m a terrible speller. I often misspell words or make typos when working in a code editor that doesn’t have spell checking abilities. So, how does one go about checking the spelling in such files? Copying and pasting into a different application to check spelling can cause problems with formatting and remove your nice Markdown or HTML code you’ve been working on. Well, never fear, Linux command line tools are here to help!
I’ve found the aspell utility very helpful for catching and quickly fixing spelling errors. Simply run it on your file and follow the on screen prompts to correct your errors, add words to the dictionary, etc.
Get started with a simple:
aspell check file.ext
So, now I no longer have an excuse for posting misspelled words on this site! 😄
BONUS: Add Grammar Checking Too!
There’s an open source tool and API out there called LanguageTool that is similar to Grammarly in that it checks grammar in addition to spelling. To use this API from the command line, you can install pylanguagetool.
First make sure that you have Python Pip installed. Then install pylanguagetool with the following command.
pip install pylanguagetool
After installing pylanguagetool, you can check the grammar on your files by simply running