I need delete a matching line and one previous to it. e.g In file below I need to remove lines 1 & 2.
I tried \"grep -v -B 1 \"page.of.\" 1.txt and I
Not too familiar with sed, but here's a perl expression to do the trick:
cat FILE | perl -e '@a = ; for( $i=0 ; $i <= $#a ; $i++ ) { if($i > 0 && $a[$i] =~ /xxxx/) { $a[$i] = ""; $a[$i-1] = ""; } } print @a;'
edit:
where "xxxx" is what you are trying to match.