Re: Beginner -
Jim Hill <[email protected]>
| Newsgroups | gmane.editors.sed.user |
|---|---|
| Message-ID | <CAEE75_06o75VJFYn_FOtOeZpKnQstx+oLcmcec7cLpe7k191hw@mail.gmail.com> |
I'm sorry, my previous was very incomplete. Here's the real one:
sed -nr '
/^primary$/!{H;$!d;g}
// {x;1d}
s/.*\n *\*Slot ([0-9]*).*\n(( *)Slot \1[^\n]*\n(\3 [^\n]*\n)*).*/\2/
s/.*\n( *Touch: [^\n]*).*/\1/p
'
The first substitution backreferences are: \1 is the slot number, \2 is
the entire slot group, \3 is the number of leading spaces before the slot
group header line, it searches for the slot group header and the following
lines with at least that much indentation.