Re: Extrace only 2 lines
Davide Brini <[email protected]>
| Newsgroups | gmane.editors.sed.user |
|---|---|
| Message-ID | <[email protected]> |
On 17 Feb 2014 12:53:34 -0800, <[email protected]> wrote: > Sample data > > 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 > Slot 2 > No loads file > > > I know that > > sed '/primary/,/\*/!d' file gives me > primary > Factory CTS 1.9.6(2) P1 > *Slot 1 CTS 1.9.6(2) P1 > > But . how do I extract only the primary line and first "*Slot" ? Well, of course you can do sed -n '/primary/p; /\*Slot/p' but I suspect your real problem is different, as it happens so many times. -- D.