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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -