Re: Extrace only 2 lines

Joel Hammer <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <1392988091.25526.3.camel@JoelsLinuxLapTop>
This seems trivial. 
1.Print first line
2.Search  for Slot. Print this line and exit.

That's it?

Here is a script.

sed -n "1p;/Slot/{p;q}" yourdata


On Mon, 2014-02-17 at 12:53 -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

> 
> 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" ?
> 
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.