Computing.Net > Forums > Programming > Sed Command : Line Start with

Sed Command : Line Start with

Reply to Message Icon

Original Message
Name: benjagol
Date: May 30, 2005 at 03:08:06 Pacific
Subject: Sed Command : Line Start with
OS: WIN2000
CPU/Ram: 4/2
Comment:

Hi,

I need to append to previous line all the line not starting by 2005, here is a example :

2005abcdefghij .....
1234567 ....
2005abcdefghij .....

The result should be
2005abcdefghij ..... 1234567
2005abcdefghij .....

Apparently, sed command could help for that :
sed -e :a -e '/$!N;s/\N2005/ /;ta' -e ...

But I don't know exactly how to do that ...
Please help !
Tks


Report Offensive Message For Removal

Response Number 1
Name: Wolfbone
Date: May 31, 2005 at 05:18:18 Pacific
Subject: Sed Command : Line Start with
Reply: (edit)

sed -e ': a {N;s/\(2005.*\n\)\(2005.*\)/\1\n\2/;s/\(2005.*\)\n\(.*\)/\1\2/;s/\n\n/\n/;b a}'

... assuming no blank lines.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Sed Command : Line Start with

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software