From the many hits about searching a pattern and printing the lines until the end of the pattern, I've encountered an issue. The solution works if there is no other entry that is similar or has the common numbers in the pattern. Let me explain.
startpat=30.202.10.0
endpat=31.202.10.0
inputfile is as follows:
30.202.10.0
abcd
efgh
31.202.10.0
ijkl
mnop
130.202.10.0
qrst
uvwx
awk -v startpat="${startpat}" -v endpat="${endpat}" '$0 ~ startpat{ x = 1} $0 ~ endpat{ x = 0}x' inputfile
I get the expected output. The problem arises when the data contains as an example 130.202.10.0. The result contains lines
abcd
efgh
qrst
uvwx
How do I get as follows
abcd
efgh