I would like to add some customer flags in some of my scripts for it to be parsed before packaging by a shell script.
Let's say, removing all multiline text between
^([#]|[//]){0,1}[_]+NOT_FOR_CUSTOMER_BEGIN[_]+\n
and between
^([#]|[//]){0,1}[_]+NOT_FOR_CUSTOMER_END[_]+\n
I want it to be error tolerant (about the number of '_') that is why i'm using regexes.
For instance:
before.foo
i want this
#____NOT_FOR_CUSTOMER_BEGIN________
not this
nor this
#________NOT_FOR_CUSTOMER_END____
and this
//____NOT_FOR_CUSTOMER_BEGIN__
not this again
nor this again
//__________NOT_FOR_CUSTOMER_END____
and this again
will become:
after.foo
i want this
and this
and this again
I'd rather use sed but any clever solution will be welcomed :)
Something like this:
cat before.foo | tr '\n' '\a' | sed -r 's/([#]|[//]){0,1}[_]+NOT_FOR_CUSTOMER_BEGIN[_]+\a.*\a([#]|[//]){0,1}[_]+NOT_FOR_CUSTOMER_END[_]+\a/\a/g' | tr '\a' '\n' > after.foo