Bash 请检查每行的拼写

Bash 请检查每行的拼写,bash,scripting,aspell,Bash,Scripting,Aspell,我想写一个bash过滤器,它将接收一个由新行分隔的句子组成的文件,并返回没有拼写错误的句子。我一直在想阿斯佩尔,但我不知道该怎么办。有什么想法吗?这根管子应该会给出你想要的结果。请注意,您应该通过管道将某些内容插入其中,因此请预先准备例如cat input.txt以进行快速测试 while read line; do [ "$(ispell -l <<< "$line" | wc -l)" -gt 0 ] && echo "$line"; done 如果您喜欢

我想写一个bash过滤器,它将接收一个由新行分隔的句子组成的文件,并返回没有拼写错误的句子。我一直在想阿斯佩尔,但我不知道该怎么办。有什么想法吗?

这根管子应该会给出你想要的结果。请注意,您应该通过管道将某些内容插入其中,因此请预先准备例如
cat input.txt
以进行快速测试

while read line; do [ "$(ispell -l <<< "$line" | wc -l)" -gt 0 ] && echo "$line"; done

如果您喜欢

这里有一个脚本,它可以满足您的需要

#!/bin/bash

# Regex for lines describing "good words":
# - empty lines (after each line of input, i.e. at the end)
# - lines with only a '*' (indicating a good word)
# - a line with '@(#) '   (at the start of the output)
# All other lines indicate a bad word.
good_words='^[*]?$|^@\(#\) '

while read # read one line of input
do
    echo $REPLY | # pipe the line to aspell
    aspell pipe | # let aspell check the line
    egrep -q -v $good_words || # have a look if aspell found misspellings
    # no words with mistake, output the line
    echo $REPLY
done
grep-v“$(aspell list
修复了我最初发布的帖子(3分钟后)的一个问题,并将命令缩短为始终:两个半小时一个没有答案,然后在五分钟内两个(非常相似)答案。我认为这是问题类型的属性。我猜有10秒的问题,30分钟的问题,2.5小时的问题和1周的问题(其他的都结束了)。它就像一个问题的
本征频率z
script.sh < input.txt
#!/bin/bash

# Regex for lines describing "good words":
# - empty lines (after each line of input, i.e. at the end)
# - lines with only a '*' (indicating a good word)
# - a line with '@(#) '   (at the start of the output)
# All other lines indicate a bad word.
good_words='^[*]?$|^@\(#\) '

while read # read one line of input
do
    echo $REPLY | # pipe the line to aspell
    aspell pipe | # let aspell check the line
    egrep -q -v $good_words || # have a look if aspell found misspellings
    # no words with mistake, output the line
    echo $REPLY
done
grep -v "$(aspell list < file)" file