delete previous and 3 following lines
Posted: Thu Jul 16, 2009 9:28 am
Hello,
I have a file of about 40000 lines, it is composed of a blank line than 5 lines of text than a blank line and 5 lines..... always the same pattern.
In the second line of text, I need to locate a string of characters ( always the same ), if found I need to delete the line, the previous line and the next 3 ones. Is there a way to delete the Previous line ?
pattern as follows:
blank line
line1 hgtrefde hrterfde uyhrfrsg yrhtgreerdefd yrhgfd
line2 ujyhg rtgfr rtgf ABCDEF tyhrtgfer ythgf utyhg
line3 uythrgf yhtrgd grezrrzg ryrthg terg 'ehg tregf rer
line4 ythrtgrteg vfc rtg teg trg rteg rtg
blank line
If I find ABCDEF in line2 I need to delete line1/line2/line3/line4
otherwise do nothing
Thank you for your help
I have a file of about 40000 lines, it is composed of a blank line than 5 lines of text than a blank line and 5 lines..... always the same pattern.
In the second line of text, I need to locate a string of characters ( always the same ), if found I need to delete the line, the previous line and the next 3 ones. Is there a way to delete the Previous line ?
pattern as follows:
blank line
line1 hgtrefde hrterfde uyhrfrsg yrhtgreerdefd yrhgfd
line2 ujyhg rtgfr rtgf ABCDEF tyhrtgfer ythgf utyhg
line3 uythrgf yhtrgd grezrrzg ryrthg terg 'ehg tregf rer
line4 ythrtgrteg vfc rtg teg trg rteg rtg
blank line
If I find ABCDEF in line2 I need to delete line1/line2/line3/line4
otherwise do nothing
Thank you for your help