Junk Food for the Brain

Open Source and Awesomesauce :)

Check Your Spelling in Linux Using the Command Line

| Comments

You can do a spell check on from the command line in Linux.

First, make sure you have aspell installed. In Fedora, just yum install it.

$ yum install aspell

You’ll also need a dictionary, from which aspell can search for words. A yum search aspell will give you a list.

[raja@atreides visilon]$ yum search aspell
-----------------------------------------------------------
aspell-af.i586 : Afrikaans dictionaries for Aspell
aspell-bg.i586 : Bulgarian dictionaries for Aspell
aspell-br.i586 : Breton dictionaries for Aspell
aspell-ca.i586 : Catalan dictionaries for Aspell
aspell-cs.i586 : Czech dictionaries for Aspell
aspell-cy.i586 : Welsh dictionaries for Aspell
aspell-da.i586 : Danish dictionaries for Aspell
aspell-de.i586 : German dictionaries for Aspell
aspell-el.i586 : Greek dictionaries for Aspell
aspell-en.i586 : English dictionaries for Aspell
aspell-es.i586 : Spanish dictionaries for Aspell
aspell-fr.i586 : French dictionaries for Aspell
aspell-ga.i586 : Irish dictionaries for Aspell
aspell-gl.i586 : Galician dictionaries for Aspell
aspell-hr.i586 : Croatian dictionaries for Aspell
aspell-id.i586 : Indonesian dictionaries for Aspell
aspell-is.i586 : Icelandic dictionaries for Aspell
aspell-it.i586 : Italian dictionaries for Aspell
aspell-no.i586 : Norwegian dictionaries for Aspell
aspell-pl.i586 : Polish dictionaries for Aspell
aspell-pt.i586 : Portuguese dictionaries for Aspell
aspell-ru.i586 : Russian dictionaries for Aspell
aspell-sl.i586 : Slovenian dictionaries for Aspell
aspell-sr.i586 : Serbian dictionaries for Aspell
aspell-sv.i586 : Swedish dictionaries for Aspell
aspell-fo.i586 : Faeroese dictionaries for Aspell
aspell-gd.i586 : Gaelic dictionaries for Aspell
aspell-nl.i586 : Dutch dictionaries for Aspell
aspell-ar.i586 : Arabic dictionary for Aspell
aspell-bn.i586 : GNU Aspell Bengali Dictionary Package
aspell-gu.i586 : GNU Aspell Gujarati Dictionary Package
aspell-he.i586 : Hebrew dictionary for Aspell
aspell-hi.i586 : GNU Aspell Hindi Dictionary Package
aspell-ml.i586 : GNU Aspell Malayalam Dictionary Package
aspell-mr.i586 : GNU Aspell Marathi Dictionary Package
aspell-or.i586 : GNU Aspell Oriya Dictionary Package
aspell-pa.i586 : GNU Aspell Punjabi Dictionary Package
aspell-sk.i586 : Slovak dictionaries for Aspell
aspell-ta.i586 : GNU Aspell Tamil Dictionary Package
aspell-te.i586 : GNU Aspell Telugu Dictionary Package

That’s a lot of languages. I’ll just install the English dictionaries.

yum install aspell-en.i586

Now the fun part. Checking your spelling via command line. Just type aspell -a and it will give you a prompt. I’ll intentionally type a misspelled word and see what it returns:-

[raja@atreides visilon]$ aspell -a
@(#) International Ispell Version 3.1.20 (but really Aspell 0.60.6)
psychatrist
& psychatrist 5 0: psychiatrist, psychiatrists, psychiatrist's, psychiatry's, psychiatric

I spelt ‘psychiatrist’ wrongly, and it gave me back a few suggested corrections. (Ok I admit, I didn’t know how to spell it in the first place. :P )

Lets see what happens when you give it a correctly spelled word:-

[raja@atreides visilon]$ aspell -a
@(#) International Ispell Version 3.1.20 (but really Aspell 0.60.6)
disapprove
*

Yes, it returns an asterisk(*), showing you’re spelling is correct. Press Ctrl + D when you’re done, to bring you back to the command line.

If you have a text file, you could check that using aspell as well. For example, here’s some sample text:-

Mary had a little lamb. It's fleede was whote as snow.

We’ll save it as mary.txt and run aspell like this to check the file:

aspell check mary.txt

You’ll get a interface like this, highlighting every misspelled word, with the suggested actions. [caption id=”attachment_217” align=”aligncenter” width=”300” caption=”Aspell in action”]Aspell in
action[/caption]

When done with the checking, aspell will exit, saving the previous copy with a .bak extension. :)