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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Sed Command : Line Start with

Reply to Message Icon

Name: benjagol
Date: May 30, 2005 at 03:08:06 Pacific
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



Sponsored Link
Ads by Google

Response Number 1
Name: Wolfbone
Date: May 31, 2005 at 05:18:18 Pacific
Reply:

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.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Sed Command : Line Start with

Batch - find line that starts with string www.computing.net/answers/programming/batch-find-line-that-starts-with-string/19499.html

Batch file command line args www.computing.net/answers/programming/batch-file-command-line-args/4226.html

Command line arguments in VisualC++ www.computing.net/answers/programming/command-line-arguments-in-visualc/6012.html