Extracting Range of lines in perl

Saturday, December 29, 2012 0 Comments

My final output file should contain only the the ranges between all IF's and END-IF's seperated by \n\n AND if there is an IF within an IF block, The range starting from the first if to the line before the second IF should be saved in FINAL seperated by \n\n


Solution for this is:


if you want IF and END-IF to be excluded,then use the below:

    perl -lne 'if(/IF/.../END-IF/ and $_!~/^\*|IF|END-IF/){print}' your_file

if you want IF and END-IF to be included,then use the below:

    perl -lne 'if(/IF/.../END-IF/ and $_!~/^\*/){print}' your_file

0 comments: