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

bash, linux, macos, vim

Solution

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

Problem

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.

Original source