Computing.Net > Forums > Unix > replace a complex string using sed

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.

replace a complex string using sed

Reply to Message Icon

Name: may
Date: December 2, 2003 at 07:42:54 Pacific
OS: W2K
Comment:

Hello,
I want to replace in a file a string with another string like the example:

file name: Test
String1 = ggggg (exist in the file Test)
String2 = /tcwork/nirgr/fffff


the following doesn't work because of the slash:
sed 's/gggg/ /tcwork/nirgr/fffff /g' Test

Do you have any idea?

Thanks may



Sponsored Link
Ads by Google

Response Number 1
Name: Nails
Date: December 2, 2003 at 13:32:22 Pacific
Reply:

Hi:

You need to escape the slashes:

sed 's/gggg/ \/tcwork\/nirgr\/fffff /g' Test

Regards,

Nails


0

Response Number 2
Name: David Perry
Date: December 4, 2003 at 05:57:19 Pacific
Reply:

Or you can use different delimeter characters for sed.

sed -e 's,gggg,/tcwork/nirgr/fffff,g' Test



0

Sponsored Link
Ads by Google
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 Unix Forum Home


Sponsored links

Ads by Google


Results for: replace a complex string using sed

How to use 'sed' on windows XP. www.computing.net/answers/unix/how-to-use-sed-on-windows-xp/6605.html

replace a newline with string www.computing.net/answers/unix/replace-a-newline-with-string/4658.html

Replace a string in Script www.computing.net/answers/unix/replace-a-string-in-script/7047.html