you just gave a complex (I donโt know what I should call it good or bad ^ _ ^) example. Your text has exactly the same startpattern and endpattern ( # )
I think you are looking for the same thing as sed '/#/,/#/d' or sed -n '/#/,/#/!p'
In awk, there is some similiar (not the same as sed) address model. There is an explanation on the man page. I did not say the same, your example is good. if start == end the address model for awk will not work:
kent$ echo "abd hfdh # fafa deafa 123 # end"|awk '/#/,/#/{next}1' abd hfdh fafa deafa 123 end
because awk matches the same line (check the man page again), but if they are different, see this example:
kent$ echo "abd hfdh # fafa deafa 123 ## end"|awk '/#/,/##/{next}1' abd hfdh end
he will give what you want. therefore, if so, you can simply do:
awk '/start/,/end/{next}1'
yes, very similar to sed.
If the start and end are really the same, you want to do it with awk, you need a flag.
kent$ echo "abd hfdh # fafa deafa 123 # end"|awk '/#/&&!f{f=1;next}f&&/#/{f=0;next}!f' abd hfdh end
well, in the example itโs better to use ^#$ , but thatโs not the point. Hope this answers your question.