Computing.Net > Forums > Linux > KSH + Sed - String Processing

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.

KSH + Sed - String Processing

Reply to Message Icon

Name: Hugh
Date: December 7, 2003 at 16:27:19 Pacific
OS: Linux
CPU/Ram: 700Mhz,384Mb
Comment:

I'm writing a script, part of which replaces all occurances of string_A with string_B in a file. Everything works fine until I have to replace a string with '/'s.

I've tried;
var=`echo "$src" | sed -e "s/\//\\\//g"`

How can i escape the damn '/'s so I can use it with sed :) Or maybe there's another *IX command that will do the trick for me?

Thanks in advnce to anyone who replies.

Hugh




Sponsored Link
Ads by Google

Response Number 1
Name: Hugh
Date: December 7, 2003 at 16:38:12 Pacific
Reply:

Found it!

Use a different seperator char with sed;

sed "s#k#main#g" sourcefile.c >destfile.c
sed "sxkxmainxg" sourcefile.c >destfile.c

woohoo!

:)



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 Linux Forum Home


Sponsored links

Ads by Google


Results for: KSH + Sed - String Processing

gawk & updatedb www.computing.net/answers/linux/gawk-amp-updatedb/28353.html

rename script www.computing.net/answers/linux/rename-script/20950.html

want to insert string in file www.computing.net/answers/linux/want-to-insert-string-in-file/26262.html