I see there are ways to print lines between two search patterns, as explained here How to grep lines between start and end pattern?
sed -n '/aaa/,/cdn/p' file
awk '/test1/,/test2/'
I need negation of the above, and finding it hard to get the correct command/solution using the standard unix commands grep/sed/awk.
grep -v excludes the lines matching the words, but not all the line between two specific regexs.
Any hints?
awksolution.. work perfectly. so the {next} block does what exactly? please elaborate – mtk Apr 25 '19 at 12:59{next}block is needed to work around a limitation / design bug inawk-- the fact the range (/pat1/,/pat2) is not a real expression, and cannot be negated or used in a conditional. That was fixed inperl, where you can do the obvious:perl -ne 'print unless /test1/../test2/'– Apr 25 '19 at 21:44sed, so you could also writesed -n '/pat1/,/pat2/!p'. – Apr 25 '19 at 21:48