开发者

bash - remove improper words

开发者 https://www.devze.com 2023-01-22 19:51 出处:网络
I have a file with bunch of words inwhich many of them don\'t make much sense such as \'completem开发者_如何学Goakes\' or even #s mixed with letters/words. What I need is to use a tool to spell check

I have a file with bunch of words in which many of them don't make much sense such as 'completem开发者_如何学Goakes' or even #s mixed with letters/words. What I need is to use a tool to spell check them, if it exists on the dictionary leave it, if not delete it.

What would be a good way of doing this in bash?

Thanks


You can script Aspell.


I had some fun with getting a single quote character in here, but hey, it should be as hard to read as it was to write, right? (assuming your words are listed in words.txt)

awk 'system("grep -i -q " "'"'"'^"$0"$'"'"'" " /usr/share/dict/words") == 0 {print $0};' words.txt
0

精彩评论

暂无评论...
验证码 换一张
取 消