多行字符串中的精确字符串匹配

时间:2014-06-19 08:39:55

标签: awk

我有一个字符串如下所示,如果字符串"abc.properties abc Scanner directory: /xyz/xzy/"存在,我需要完全匹配。

我正在使用下面的awk命令。

如果字符串的一部分,即abc.properties存在,它认为是成功的。但是,我的标准是检查确切的字符串,即"abc.properties abc Scanner directory: /xyz/xzy/"

有人可以帮忙吗?

echo $s | awk 'BEGIN { FS="\n"; RS="";} /abc.properties abc Scanner directory: \/xyz/xzy\// {print $1}'

字符串如下:

spawn ssh -oStrictHostKeyChecking=no -oCheckHostIP=no -o ServerAliveInterval=600 -o ServerAliveCountMax=3 -o ConnectTimeout=30 xyz@123.abc.com Password: Creating directory '/home/xyz'. Authorized uses only. All activity may be monitored and reported. Successful login using -u option. If you want to allow X traffic please use -x option. Usage: /111/11/111/111 [policy] -x [target user] su from xyz to abc [abc@xyz ~]$ /111/111/111/111/111/111.sh /111/11/instance/111/111/111/111/ Verifying JVM setting for domain: /111/11/11/11/1111/111/111// abc.properties abc Scanner directory: /xyz/xzy/ [abc@xyz ~]$ exit 0 logout

输出如下:

$ echo $s | awk 'BEGIN { FS="\n"; RS="";} /abc.properties abc Scanner directory:   \/xyz/xzy\// {print $1}'

spawn ssh -oStrictHostKeyChecking=no -oCheckHostIP=no -o ServerAliveInterval=600 -o ServerAliveCountMax=3 -o ConnectTimeout=30 xyz@123.abc.com Password: Creating directory '/home/xyz'. Authorized uses only. All activity may be monitored and reported. Successful login using -u option. If you want to allow X traffic please use -x option. Usage: /111/11/111/111 [policy] -x [target user] su from xyz to abc [abc@xyz ~]$ /111/111/111/111/111/111.sh /111/11/instance/111/111/111/111/ Verifying JVM setting for domain: /111/11/11/11/1111/111/111// abc.properties abc Scanner directory: /xyz/xzy/ [abc@xyz ~]$ exit 0 logout

0 个答案:

没有答案