so have log file looks this:
event-header apple orange peach blueberry event-header bike car blueberry event-header reddit hacker news stack overflow slashdot? voat what trying extract blocks of text (from event-header 2 newlines before next event-header) contain word "peach".
i think problem regex solve, having trouble making regex this. here's have come far:
's/event-header((?!\n\n).)+peach((?!\n\n).)+\n\n/&/p' i'm not expert @ this. there easy way using regex/perl?
you can using paragraph mode makes perl read blocks of text delimited blank lines
perl -00 -ne'print if /peach/' logfile.log if prefer full program file looks this
use strict; use warnings; open $fh, '<', 'logfile.log' or die $!; { local $/ = ''; while ( <$fh> ) { print if /peach/; } }
Comments
Post a Comment