You can use aspell -a
to do this, and take the file from stdout. This will output the word with line number and alternate spellings:
cat example.txt | aspell -a
To clean up your list better, I'd use something more like:
cat aspell.txt | aspell -a | cut --delimiter ' ' --fields 2 | grep --invert-match '*'
Explaining the second set of commands:
The output of aspell -a
has a *
for correctly spelled words, and mispelled words have output like this:
& dev 26 101: Devi, derv, DEC, Dec, deb, DE, def, div, Dave, dive, dove, DEA, Dee, dew, Del, Dem, Nev, Rev, deg, den, rev, Davy, deaf, defy, diva, TV
dev
is the misspelled word here, which is in the second "column" when delimiting by spaces. So we pipe the aspell
output to cut
to get only the second column. We also pipe to grep
to remove all the lines with *
.
You can also append | sort | uniq
to list misspelled words only once even if they appear in the text multiple times.