简体   繁体   English

Perl Oneliner正则表达式

[英]Perl Oneliner Regex

I need to log results from a file to the screen. 我需要将结果从文件记录到屏幕上。

cat logfile.txt 猫logfile.txt

=====================Installing Oracle========================
*** ERROR[Install023] Oracle is already installed in $VOL1.
Alert: There might be an issue, Please check!
=============================================
=====================File Set verification========================
Filesystem    State    512-blocks       Used       Avail  Capacity  Mounted on
HOME          STARTED   143372688   119516872    23855816   83%    /home
BIN       STOPPED        -           -           -        -    /nfsT/nfsdata/common
ROOT          STARTED   143372688   119516872    23855816   83%    /
TEMP          STARTED   143372688   118402344    24970344   83%    /tmp
The Filset for home directory looks Ok.
The Filset for root directory looks Ok.
=============================================

I am doing: 我在做:

perl -0777 -nle  'print $2 "\n" while m/^(={21})([\w\s]+)(+={24})/gm' logfile.txt

But it is not giving any result. 但这没有任何结果。

The out put needs to be. 输出需要。

Installing Oracle..... Alert
File Set verification.....Ok!

It's not clear what all the possible reasons for an alert could be, but the following works for your sample: 尚不清楚发出警报的所有可能原因是什么,但是以下示例适用于您的示例:

perl -ne 'undef $err, print "$1 ..." if /^={21}([^=]+)={24}/;
          $err = 1 if /ERROR/;
          print $err ? "Alert" : "Ok!", "\n" if /={45}/'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM