regex - Perl one liner to remove multiple line -


input file is

<section_begin>  mxsqlc   *** warning[13052] cursor c not fetched. <section_end> <section_begin>  b2.lst *   *** warning[13052] cursor c not fetched.  0 errors, 1 warnings in sql c file "b2.ppp". <section_end> <section_begin>  b2s0 sqlcode=0 sqlstate=00000 a=10, b=abc, c=20 sqlcode=0 sqlstate=00000 a=10, b=abc      , c=10, d=xyz       <section_end> 

expecting output without below lines.

<section_end> <section_begin>  b2s0 

my code

perl -ne 'print unless /^\<section_end\>(\s*|.*lst)?\s*$/' b2exp 

it removes <section_end> lines , doesn't remove line <section_begin> *.lst

keep simple

perl -ne 'print unless /^\<section_/' b2exp 

bit more complicated

perl -ne 'print unless /^\<section_(end|begin)\>/' b2exp 

ah, question isn't clear. ( me, perhaps really)

i read "i have sections marked out <section_begin> tagname @ start , </section_end> @ end. wish exclude sections particular tagname, bs20 in example. wish keep other lines "

perl -ne 'begin {$p=1}  $p=0 if /section_begin.*b2s0/; print if $p; $p=1 if /<section_end>/;' ex.txt 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -