Sample of output stored in a file:
Provides: Red Hat Satellite
Red Hat Developer Toolset (for RHEL Server)
SKU: TGV123
Contract: 59104
Pool ID: abcdxyz12340987
From the above output, I want to look for "Red Hat Satellite" and look for the line containing "Pool ID:" so that I get the value of the pool ID i.e. abcdxyz12340987.
How can I obtain this using sed, awk or grep? "Pool ID" may appear several lines after "Red Hat Satellite" i.e. no set number of lines in between them.
Help much appreciated!
grep -A10 "Provides: Red Hat Satellite" file | grep "Pool ID:" | head -1 | awk '{print $2}'just change "A10" to the maximum amount of lines there is between theProvidesline and thePool IDline