I need to get a clean txt document and my first approach is to use aspell. The issue is I need it on batch, no interactive mode. Every txt file is piped to aspell and must be returned a new document with the non-dictionnary words deleted.I've found just the inverse behaviour: list the non-dictionary words using cat $file | aspell list | sort -u -f Is aspell the correct tool to achieve that cleaned document folder? What about automatic substitution of misspelled words? (using a predefined list file)
filter document via aspell
batch jobs;dictionary;aspell
sed -E -e s/$(aspell list <file | sort -u | paste -s -d'|' |               sed -e 's/^/\\b(/; s/$/)\\b/' )//g \    file > newfileThis uses command substitution $(...) to insert the output of aspell list <$file into a sed search and replace operation.aspell's output is also unique sorted and paste is used to join each line with |.  Finally it is piped through sed to add \b word-boundary anchors as well as open and close parentheses.  All of which constructs a valid extended regular expression like \b(word1|word2|word3|...)\b to use as the search regexp in the sed search and replace command.You can test the result of the entire command with, e.g., diff -u file newfileAFAIK, aspell doesn't have an auto-correct mode.  This is probably a Good Thing.