我要做的是获取文件中最匹配的单词以及使用agrep
. 现在我只能使用这个脚本来获取这个词:
array=(bla1 bla2 bla3)
for eachWord in "${array[@]}"; do
result=$(yes "yes" | agrep -B ${eachWord} /home/victoria/file.txt)
printf "$result\n"
done
其中bla{1,2,3}是一些单词。
我的输出如下:
agrep: 4 words match within 2 errors; search for them? (y/n)counting
first
and
should
agrep: 1 word matches within 1 error; search for it? (y/n)should
agrep: 2 words match within 4 errors; search for them? (y/n)must
must
agrep: 1 word matches within 2 errors; search for it? (y/n)should
有什么方法可以让我获得错误数量(上面的输出示例中的2,1,4,2 )?