Skip to content

Quick command line spell check of a single word or sentence

Here’s a short bash script, using aspell, to spell check a word or several words from the command line. It’s simple but effective. If anyone else knows a cleaner or even simpler way, please let us know.


#!/bin/bash

WORD=$1
TEMPFILE=temp.spell

echo $WORD > $TEMPFILE
aspell -c $TEMPFILE
cat $TEMPFILE
rm -f $TEMPFILE
rm -f $TEMPFILE.bak

I named this script “spell”. Simply use it like so:

$ spell reccomend

Aspell will run and you can make your changes.

reccomend

1) recommends 6) commend
2) recommend 7) recommenced
3) reckoned 8) recommended
4) regiment 9) Redmond
5) recombined 0) rejoined
i) Ignore I) Ignore all
r) Replace R) Replace all
a) Add l) Add Lower
b) Abort x) Exit

In this case, if I type “2″, the correction will be made, aspell will exit and the spelling I chose gets printed out.

Here’s an example of how to use it with a sentence.

$ spell "I go to the storede and buy beakh clotes"

Now aspell will take you through each misspelled word. After you finish the corrections it will exit and print out the corrected sentence or series of words.

I go to the store and buy beach clothes

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

4 Comments

  1. Joshua wrote:

    Hi there

    I’m really sorry for mis-using this comment box, but I didn’t find another easy way to contact your guys.
    I found a link to an archived page of your website, but this link doesn’t work anymore. It’s http://reverttoconsole.com/archives/169 from an Apple discussion thread, http://discussions.apple.com/thread.jspa?threadID=1264582.
    I’d be really interested in the content of this link, so is it still available somewhere?

    Thanks a lot for reply.
    Joshua

    Sunday, September 6, 2009 at 12:42 pm | Permalink
  2. Priyatam wrote:

    it’s here

    Sunday, September 6, 2009 at 10:48 pm | Permalink
  3. Jason Lewis wrote:

    or try:

    echo reccomend | aspell -a

    Sunday, May 15, 2011 at 9:40 pm | Permalink
  4. Steve wrote:

    Excellent Jason. Thanks for sharing!

    Monday, May 16, 2011 at 9:43 am | Permalink

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*