I have a file in the format:
Port Number
IP address
Port Number
IP address
(Not sure how the output will be displayed here but let me tell you they are on separate lines)
and so on....
I use the command grep -C 1 'port number' file.txt
i.e. I want all IP addresses corresponding to a particular port. Making it simple, I want the next line matching a regular expression. Like if my regular expression matches line 2,4 and 6 then I want lines 3, 5 and 7 to be printed. How to do that?