logo       

Re: can sed take take several line to produce multiple output: msg#00028

editors.sed.user

Subject: Re: can sed take take several line to produce multiple output

shamrul ismawi wrote:

> The input file is using same format for every 2
> line(delimiter is ,)
>
>
> Can sed take the following input:
>
> header,login - telnet ssh, Thu Dec 08 11:08:55 2005,
> subject,abc,def,123,456, abc.linux.com.my
>
>
> and produce:
>
> Thu Dec 08 11:08:55 2005, Name=abd 2name=def phone=123
> phone2=245
> From : abc.linux.com.my Access=telnet ssh

Well, assuming that the first Name should be "abc" rather than "adb", the
answer is yes.

The trick is to read in the data in pairs of lines rather than one line at
a time which is how sed operates by default.

$ sed -f trial.sed input.txt
Thu Dec 08 11:08:55 2005, Name=abc 2name=def phone=123 phone2=456
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise