Reputation: 103
One line starting with \hello is skipped using
awk '/\\hello/{next}'
How to edit the command above to skip lines between \hello and \hello2?
input
text
\hello
text
hi
\hello2
text2
desired output:
text
text2
Upvotes: 0
Views: 581
Reputation: 26471
In its not recommended way, you can do the following:
$ awk '/^\\hello$/,/^\\hello2$/{next}1' file
The better, more adaptable way is:
$ awk '/^\\hello$/{f=1}(f==0){print};/^\\hello2$/{f=0}' file
which is reducible too:
$ awk '/^\\hello$/{f=1}!f;/^\\hello2$/{f=0}' file
or see Ed Morton's comment (see below)
Upvotes: 3