Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spell checking a file using command line, non-interactively

I have a large text file, containing many miss/bad-spelled English words. I'm looking for a way to edit this file using a command-line spell checker in Linux. I found some ways to do this, But according to my searches all of them work in an interactive manner. I mean, seeing a miss/bad-spelled word, they suggest some corrections to the user and he/she should choose one of them. Since my file is rather large, and contains many wrong words, I can't edit it in this manner. I am looking for a way to tell the spell-checker that replace all the wrong words using the first candidate. Is there any way to do this? does (a/hun)spell have any option for doing so?

Regards.

like image 854
Hakim Avatar asked Sep 17 '12 04:09

Hakim


1 Answers

If you don't need it to replace every wrong word, but simply point out the errors and print suggestions in a non-interactive manner, you can use ispell:

$ ispell -a < file.txt | grep ^\& > errors.txt

I'm unfortunately not aware of any standard Linux utility that does what you're requesting from the command line, although the emacs suggestion in the comments above comes close.

like image 185
Kyle Barbour Avatar answered Sep 21 '22 07:09

Kyle Barbour