Set Well = `nawk -v qq='"' 'c&&!--c {print substr($0, index($0,qq))};$NF ~ "WELL:" {c=2;next}' $file`
echo $Well
I got the following message:
1: Event not found
Perhaps I should have added that I am using Cshell and that the 3 data lines shown in my original post are part of a larger file. The string "WELL:" however is the first instance of that string in the file. Hope that doesn't make it more difficult.
The actual file is immense, so I'll just add a few lines of particular interest to me. There is a problem reading other lines where the number of parameters varies as in the following:
In this case I only get "BATTELLE MEMORIAL" returned. The string that I need to retrieve in each case will always be enclosed in double quotes at the end of the second line below the line containing the marker. Within those quotes, there may be any number of spaces. Sorry I didn't clarify that earlier. Is that still doable?
Despite trying various modifications of the awk command I was not able to get it to work.
The sed command came very close though. It returned the desired string, but also a second undesired line. My input lines of interest are:
I need to retrieve the string contained in quotes on the second line below the marker line. So for the above, I need to retrieve "AEPAEP" for WELL:, "MOUNTAINEER" for FIELD:, and "BATTELLE MEMORIAL INSTITUTE" for COMPANY:, etc, (minus the double quotes.)
The sed command returned the following:
AEPAEP
FIELD:
Thanks for everyone's help on this. While I can decipher most CShell code, sed and awk are from a different planetary system.
Thanks,
Paul H.
I need to retrieve the string contained in quotes on the second line below the marker line. So for the above, I need to retrieve "AEPAEP" for WELL:, "MOUNTAINEER" for FIELD:, and "BATTELLE MEMORIAL INSTITUTE" for COMPANY:, etc, (minus the double quotes.)
The sed command returned the following:
AEPAEP
FIELD:
Thanks for everyone's help on this. While I can decipher most CShell code, sed and awk are from a different planetary system.