Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run spell check on multiple files and display any incorrect words in shell script?

I have a few files I wish to spellcheck. Normally I would open these in vim, run :set spell and do the changes. It's really teadious to open files and manually check if I've misspelt any words since the last check, however.

Is there a way I can run a spell-check on a lot of files and display any incorrectly-spelt words found, along with the filename, so that I can go and change them? I don't want to open every file, check if it's "clean", then open the next and repeat.

I can't find any POSIX spellcheck utility. Some Red-Hat based Linux distributions allegedly have spell or similar, but I'd prefer a cross-platform(ish) method. I know vim can spellcheck - is there any way of spellchecking without doing it all manually? It'd be fantastic if I could shell-script a solution.

I'm running OS X, for what it's worth.

like image 616
simont Avatar asked Oct 09 '12 12:10

simont


People also ask

How do you use Aspell command?

Type a word in this mode, press enter, and you'll see aspell offering spelling suggestions on stdout. Example 3: Using aspell to check words in bulk. When run, will wait for user input. Add as many words as you want, and when done, press Ctrl+D.

How do I set spell check in Vim?

vim Spell checker Spell CheckingTo turn on the vim spell checker run :set spell . To turn it off run :set nospell . If you always want the spell checker to be on, add set spell to your vimrc. You can turn spelling on only for certain filetypes using an auto command.

What is ispell in Linux?

DESCRIPTION. Ispell is fashioned after the spell program from ITS (called ispell on Twenex systems.) The most common usage is "ispell filename". In this case, ispell will display each word which does not appear in the dictionary at the top of the screen and allow you to change it.

How do you spell check in Unix?

To spellcheck a file, just run it through ispell. For example, if the file that you want to be spellchecked is named 'mispel. txt' , then you can simply run 'ispell mispel. txt' .


1 Answers

You can install aspell with Homebrew on OS X. brew info aspell lists supported languages.

brew install aspell --lang=en,fi,jp 

aspell check opens a file in an interactive spell checker:

for f in *.txt; do aspell check $f; done 

aspell list prints all unrecognized words:

cat *.txt | aspell list | sort -u 

Learned words are stored in .aspell.en.pws by default. You can also exclude words in ~/Library/Spelling/en after adding personal_ws-1.1 en as the first line.

aspell list --personal=$HOME/Library/Spelling/en 
like image 173
Lri Avatar answered Sep 17 '22 23:09

Lri