I have an archive file that holds a batch of statements. I would like to be able to extract a certain statement based on the unique customer # (ie. 123456). The end for each statement is noted by "ENDSTM".
I can find the line number for the beginning of the statement section with sed.
start=`sed -n '/123456/=' filename`
This will get me the starting line number. It is actually 5 lines before this but this is the line with the unique customer #. From here I would like to find the next occurrence of "ENDSTM" after the line where the customer # was found. Then I could do a sed to grab the section of the file I need based on the starting and ending line #s.
How would I do this? grep, sed, awk?
Or is there a way to get what I need with one command?