How to fix error agrep: pattern too long (has > 32 chars) it doesn't show error if there is no full stop in the string?

人盡茶涼 提交于 2019-12-23 03:46:11

问题


agrep gives the error agrep: pattern too long (has > 32 chars) when there is a full stop(.) in the pattern string but not otherwise.

I want to compare(approximately) two strings, so I'm using agrep for that but its giving an error agrep: pattern too long (has > 32 chars) . But I found out that it doesn't give the error if there is no full stop in the pattern string(why?)

`echo "The quick brown fox jumped over the lazy dog." | agrep -c -4 "The quick brown fox jumped over the lazy dog."`

expected output is 1 instead it gives an error: agrep: pattern too long (has > 32 chars)

it works if I remove the full stop:

$ echo "The quick brown fox jumped over the lazy dog." | agrep -c -4 "The quick brown fox jumped over the lazy dog"  
1

回答1:


Approximate string matching / fuzzy string searching with two strings.

With agrep and bash:

if agrep -1 "abc" <<< "xbc" >/dev/null; then echo "match"; else echo "no match"; fi

or with tre-agrep and bash:

if tre-agrep -q -1 "abc" <<< "xbc"; then echo "match"; else echo "no match"; fi

Output in both cases:

match


来源:https://stackoverflow.com/questions/57533885/how-to-fix-error-agrep-pattern-too-long-has-32-chars-it-doesnt-show-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!