我需要的是:
我需要删除整行但需要保留匹配的字符串。
以 a开头Unhandled
和结尾的匹配模式:
我尝试了以下打印匹配模式的代码,但我需要从文件中删除多余的行。
perl -0777 -ne 'print "Unhandled error at$1\n" while /Unhandled\ error\ at(.*?):/gs' filename
以下是示例输入:
2012-04-09 01:52:13,717 - uhrerror - 错误 - 22866 - /home/shabbir/web/middleware.py process_exception - 217 - /user/resetpassword/: : {'mod_wsgi.listener_port': '8080 ', 'HTTP_COOKIE': "__utma=1.627673239.1309689718.1333823126.1333916263.156; __utmz=1.1333636950.152.101.utmgclid=CMmkz934na8CFY4c6wod_R8JbA|utmccn=(not%20set)|utmcmd=(not%20set)|utmctr=non-stick%20kadai%20online ; subpopdd=yes; _msuuid_1690zlm11992=FCC09820-3004-413A-97A3-1088EE128CE9; _we_wk_ls_=%7Btime%3A'1322900804422'%7D; _msuuid_lf2uu38ua0=08D1CEFE-3C19-4B9E-8096-240B92BA0ADD; nevermissadeal=True; sessionid=c1e850e2e7db09e98a02415fc1ef490; __utmc =1; __utmb=1.7.10.1333916263; 'wsgi.file_wrapper': , 'HTTP_ACCEPT_ENCODING': 'gzip, deflate'}