Computing.Net > Forums > Unix > Shell script - replace paragragh

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.

Shell script - replace paragragh

Reply to Message Icon

Name: Mondragon
Date: May 26, 2005 at 02:27:22 Pacific
OS: Unix
CPU/Ram: AMD 64k
Comment:

Hi,

I have a problem where I need to extract several paragraphs beginning with the string "Start" and ending with the string "End". Is there anyway this can be done using sed?

Thanks




Sponsored Link
Ads by Google

Response Number 1
Name: kris92
Date: May 26, 2005 at 03:10:37 Pacific
Reply:


hi
you can try

sed /"start"/,/"end"/!d sourcefilename > destinationfilename

this will extract paragraphs starting with "start" and ending with "end" and store the result in destinationfilename. I ve tested it and it works



0

Response Number 2
Name: Jim Boothe
Date: May 26, 2005 at 05:27:32 Pacific
Reply:

For the expression: /"start"/
the quotation marks are part of the search string, so if you do not have quotation marks, you will need to remove those.

And here is an equivalent statement, but it uses "print only these lines" logic instead of "delete all but these lines" logic.

sed -n /Start/,/End/p


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


parameters in sed Remote PC shutdown from I...



Post Locked

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


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Shell script - replace paragragh

Shell script to replace a string www.computing.net/answers/unix/shell-script-to-replace-a-string/4987.html

Read file and replace..shell script www.computing.net/answers/unix/read-file-and-replaceshell-script/5083.html

Shell script www.computing.net/answers/unix/shell-script/4418.html