Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 用于在egrep中匹配错误字符的动态模式_Regex_Bash - Fatal编程技术网

Regex 用于在egrep中匹配错误字符的动态模式

Regex 用于在egrep中匹配错误字符的动态模式,regex,bash,Regex,Bash,我在文件中有以下几行: UserParameter=cassandra.status[*], curl -s "http://$1:$2/server-status?auto" | grep -e $3 | awk '{ print $$2 }' UserParameter=ping.status[*],curl -s --retry 3 --max-time 3 'http://localhost:1111/engines?$1' | awk '/last_seen = / {split($

我在文件中有以下几行:

UserParameter=cassandra.status[*], curl -s "http://$1:$2/server-status?auto" | grep -e $3 | awk '{ print $$2 }'

UserParameter=ping.status[*],curl -s --retry 3 --max-time 3 'http://localhost:1111/engines?$1' | awk '/last_seen = / {split($$1, a, "/"); print a[2]}; END { if (!NR) print "NO_MATCHING_ENGINES" }' | tr "\n" " 
等等

我想显示[*]后面缺少逗号的那一行,或者除了逗号之外还有其他字符

例如:

UserParameter=ping.status[*],,,curl -s --retry 3 --max-time 3 'http://localhost:1111/engines?$1' | awk '/last_seen = / {split($$1, a, "/"); print a[2]}; END { if (!NR) print "NO_MATCHING_ENGINES" }' | tr "\n" " 
UserParameter=ping.status[*] curl -s --retry 3 --max-time 3 'http://localhost:1111/engines?$1' | awk '/last_seen = / {split($$1, a, "/"); print a[2]}; END { if (!NR) print "NO_MATCHING_ENGINES" }' | tr "\n" " 
UserParameter=ping.status[*],;!curl -s --retry 3 --max-time 3 'http://localhost:1111/engines?$1' | awk '/last_seen = / {split($$1, a, "/"); print a[2]}; END { if (!NR) print "NO_MATCHING_ENGINES" }' | tr "\n" " 
只要除了单个逗号之外还有额外的字符和空格,就会打印

但是:

只要[*]后面有一个逗号,就不会打印

我试图为egrep开发一个模式,但它不适合所有情况,例如除了逗号之外,[*]后面的任何其他字符:

egrep (\[\*\].(|;|:|,|\.|))
我将感谢任何帮助!谢谢大家!

grep -vE '\[\*\],[$/[:alpha:] ]' input

不要打印与模式匹配的行:
[*],
后接任何:
$
/
,字母字符或
空格

[*],
之后的有效字符是什么?似乎“c”代表“curl”是可以的;是吗?$/可以用字母。空格怎么样?(您的第一个示例:
…status[*],curl…
)也允许使用空格,但仅在单个逗号之后,但是如果我们有status[]。。。。只要缺少逗号,就应打印字符串。美元/和字母也是如此。如果缺少逗号,则不允许在[]之后立即使用。
grep -vE '\[\*\],[$/[:alpha:] ]' input