在为多行匹配设置正则表达式时遇到问题
我试图抓取所有失败的查询(接收状态为 2)但没有成功
Perl 一行看起来像
perl -e '$text = `cat errors.log`;while($text =~ m/^request.*?(\/.*?)\n.*?receive status is 2$/sgm ){print $1."\n";}'
示例日志如下
***** test 0: *****
* Request:
request = /Lookup?url=URL1
received in 0.108 milliseconds
receive status is 2
-- STATUS : 1 --
<RESULT SET 1>
***** test 1: *****
* Request:
request = /Lookup?url=URL2
received in 44.753 milliseconds
receive status is 0
-- STATUS : 0 --
<RESULT SET 2>
***** test 2: *****
* Request:
request = /Lookup?url=URL3
received in 44.753 milliseconds
receive status is 2
-- STATUS : 3 --
<RESULT SET 3>
查看所有失败的 URL,如 URL1、URL3