I have a large file that looks something like this:
line1
line2
line3;
line5
line6;
line7
line9
line10;
Basically, it's a bunch of lines, some of which end in semicolons. There may or may not be empty lines after these lines with semicolons.
I'd like to do something that seems relatively simple with this file, but I haven't been able to come up with a way to do it. I'd like to invoke a bash script that would identify those lines that end with semicolons and echo the first nonempty line after each of them.
So, in the example above, the output would be:
line5
line7
I've tried a few different ways, including looping through the whole file, using a regex to check if the current line ends in a semicolon, and toggling a boolean variable to determine if the next nonempty line should be echoed. But I haven't had any luck.
It seems like there should be any easier way, perhaps using grep, but I can't seem to come up with it. Any ideas on a good way to implement this?