awk - Delete multiple lines - from "patternA" match, through second occurrence of "patternB" -
i'd use sed
or similar tool find line containing "something?
" , delete line , following lines until second occurrence of line containing "fi
".
example...
if have following file /somepath/somefile
containing:
... # test something? if something if somethingelse somethingelse fi fi ...
and i'd find , remove lines, starting line containing "something?
" through line containing second "fi
"
i'm able remove lines starting line containing "something?
" through end of file using sed -n '/something?/q;p'
i'm not sure how add condition stop after second line containing "fi
". appreciated.
you awk:
awk 'begin { del=0 } /test something?/ { del=2 } del<=0 { print } /fi/ { del -= 1 }' your-file
Comments
Post a Comment