Re: Beginner -
Jim Hill <[email protected]>
| Newsgroups | gmane.editors.sed.user |
|---|---|
| Message-ID | <CAEE75_1kY+TONq2=jMZN4MptBJQVPVmDo4U_X5TV9FEUHKE0VQ@mail.gmail.com> |
Using GNU sed:
sed -nr '
/^primary$/!{H;$!d;g}
// {x;1d}
s/.*\n *\*(Slot [0-9]*).*\n( *\1[^\n]*).*/\2/p
'
On Mon, Feb 24, 2014 at 8:49 AM, <[email protected]> wrote:
>
>
> Example data file 10.10.10.10.log :
>
>
> primary
> Factory CTS 1.9.6(2) P1
> *Slot 1 CTS 1.9.6(2) P1
> Slot 2 CTS 1.7.1(4864) P1
> loads file information
> Factory (cmterm-CTS.1-9-6-2R-K9.P1)
> CTS: CTS.1-9-6-2R-K9.P1.sbn
> Touch: CTSDEV.1-9-6-2R-K9.P1.SPA
> Slot 1 (cmterm-CTS.1-9-6-2R-K9.P1)
> CTS: CTS.1-9-6-2R-K9.P1.sbn
> Touch: CTSDEV.1-9-6-2R-K9.P1.SPA-G
> Slot 2
> No loads file
>
> I look for primary and * to isolate the interesting slot number.
> slot=`sed '/^primary$/,/\*/!d' 10.10.10.10.log | tail -1 | sed s'/*//' |
> awk '{print $1" "$2}'`
> slot = "Slot 1"
> Now I want to get the Touch line for the associate slot number, in this
> case, because the asterisk indicates the interesting slot, "Slot 1"
>
> sed -n '/\s+"$gslot"/p; /Touch:/p' 10.10.10.10.log
> The response
> .
> Slot 1
> Touch: CTSDEV.1-9-6-2R-K9.P1.SPA
> Touch: CTSDEV.1-9-6-2R-K9.P1.SPA-G
>
> My question is \
> How do I get only the touch line following the Slot 1 line ?
>
>