Given a file TestData.txt containg lines, where junk may be repeated N or more times, and the position of the line "Model=Default" is not fixed
...
junk
junk
Model="C"
junk
junk
Size="81"
junk
Model="Default" <---- Start of "Default" block
junk
...
junk
Size="47" <---- Required value of size (first "Size=" line after "Default")
junk
junk
Model="A"
junk
Size="22"
junk
junk
Model="T"
junk
junk
Size="32"
junk
...
and wishing to extract the value of Size for the Default case, the following works by printing the lines between the matches and then applying a second sed command to do the substitution to extract the value of size.
sed -ne '/="Default"/,/Size=/p' TestData.txt | sed -ne 's|Size="\([1-9][0-9]*\)"|\1|p'
This prints 47, the required value of the "Size" parameter from the "Default" section.
Can the two sed operations be combined into a more efficient single sed invocation?
(This is a simplified form of the actual task which is to extract, with more complicated regexps, a single value from a configuration file where there are multiple blocks containing a "size" designation.)