2014-10-16 103 views
0

我需要將結果從文件記錄到屏幕上。Perl Oneliner正則表達式

貓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. 
============================================= 

我做:

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

但它不會給任何結果。

需要輸出。

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

'的perl -0777 -wnle ...' – 2014-10-16 12:24:53

回答

1

目前尚不清楚所有警報的可能原因可能是什麼,但你的樣品以下工作:

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