I'd like to write a bash filter that will take a file of newline-separated sentences and return sentences that are not misspelled. I've been thinking about aspell but I'm not sure what to do with it. Any ideas?
This pipe should give the results you want. Note that you should pipe something into this, so prepend e.g. cat input.txt |
for a quick test.
while read line; do [ "$(ispell -l <<< "$line" | wc -l)" -gt 0 ] && echo "$line"; done
To also prepend a line number:
nl -b a -p | while read number line; do [ "$(ispell -l <<< "$line" | wc -l)" -gt 0 ] && echo "$number: $line"; done
If you want to return misspelled lines instead, just replace -gt
by -le
(or replace &&
by ||
, of course)
Of course you can save these lines as a script, and then simply do
script.sh < input.txt
if you so prefer