sed expression selecting globally, trying to pick out sections in a file
by luw from LinuxQuestions.org on (#58M1C)
Good morning I am getting overwhelmed with this problem and maybe someone here has an idea how to get me on the right path.
I have a file with the following...
Code:[GRAY_CATS]
sometext, 123, 345, 678
****
[BROWN_DOGS]
sometext, 000, 111, 222
****
[RED_FOXES]
sometext, 333, 444, 555
****I want to pull out the "000" in the BROWN_DOGS section. I have a sed expression that triggers on the 3 digits after "sometext, " and it works great. However, it pulls from all sections, not just the BROWN_DOGS section (as it should).
I'm looking to trigger on the "sometext, " that is only between the "[BROWN_DOGS]" and "****" which are guaranteed to be there. The number of lines and text before "sometext, " is them is not guaranteed, nor is the number of lines after.
Does anyone have any suggestions how to do this or at least a point in the right direction? I'm not sure how to handle the multiple lines.
Thank you folks for your time.


I have a file with the following...
Code:[GRAY_CATS]
sometext, 123, 345, 678
****
[BROWN_DOGS]
sometext, 000, 111, 222
****
[RED_FOXES]
sometext, 333, 444, 555
****I want to pull out the "000" in the BROWN_DOGS section. I have a sed expression that triggers on the 3 digits after "sometext, " and it works great. However, it pulls from all sections, not just the BROWN_DOGS section (as it should).
I'm looking to trigger on the "sometext, " that is only between the "[BROWN_DOGS]" and "****" which are guaranteed to be there. The number of lines and text before "sometext, " is them is not guaranteed, nor is the number of lines after.
Does anyone have any suggestions how to do this or at least a point in the right direction? I'm not sure how to handle the multiple lines.
Thank you folks for your time.