如何修复错误agrep:模式过长(具有32个字符),如果字符串中没有句号,则不会显示错误? [英] 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?
问题描述
agrep给出错误 agrep:模式字符串太长(具有32个字符)
,而模式字符串中有一个完整的stop(.)则不然.
agrep gives the error agrep: pattern too long (has > 32 chars)
when there is a full stop(.) in the pattern string but not otherwise.
我想比较(大约)两个字符串,所以我为此使用了agrep,但它给出了一个错误 agrep:pattern too long(具有> 32个字符)
.但是我发现,如果模式字符串中没有句号,它不会给出错误(为什么?)
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."`
预期的输出为1,而是给出错误: agrep:模式过长(具有32个字符)
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
推荐答案
具有两个字符串的近似字符串匹配/模糊字符串搜索.
Approximate string matching / fuzzy string searching with two strings.
使用 agrep
和 bash
:
if agrep -1 "abc" <<< "xbc" >/dev/null; then echo "match"; else echo "no match"; fi
或 tre-agrep
和 bash
:
if tre-agrep -q -1 "abc" <<< "xbc"; then echo "match"; else echo "no match"; fi
两种情况下的输出:
match
这篇关于如何修复错误agrep:模式过长(具有32个字符),如果字符串中没有句号,则不会显示错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!