Computing.Net > Forums > Linux > sed - how to append \ 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 - how to append \ with /

Reply to Message Icon

Name: chitti
Date: September 20, 2007 at 03:01:35 Pacific
OS: linux
CPU/Ram: 256
Product: 2006
Comment:

Hi,
Please help me in resolving this problem.
I want to use sed command to change the path of file to have '\' along with '/'
for ex:-
echo "/usr/local/chitti/my_space" | sed -n "s/\//\\\//gp"

I get
\/usr\/local\/chitti\/my_space

But when same added in bash script I get the path as
/usr/local/chitti/my_space
Any help to resolve this will be greatly appreciated.

Thanks,
chitti.




Sponsored Link
Ads by Google

Response Number 1
Name: quacked
Date: September 21, 2007 at 17:32:07 Pacific
Reply:

This might better be answered in the programming forum,,,, I did a google search on using the sed command and with the way your using it ,, I'm a little unclear as to exactly what it is your trying to accomplish ,,, Perhaps

http://www.ncsa.uiuc.edu/UserInfo/R...

would be able to help somewhat,,,

MSI 845e mb 1 gb ram and a p4 2.4n running fedora 7 xp ,win 2000 advanced server and win 98 SE alot to learn and I know so little !!!!


0

Response Number 2
Name: Guy
Date: September 22, 2007 at 16:59:15 Pacific
Reply:

Do not use double quotes around the sed script, use single quotes like:

echo "/usr/local/chitti/my_space" | sed -n 's/\//\\\//gp'


0

Response Number 3
Name: quacked
Date: September 23, 2007 at 20:11:57 Pacific
Reply:

Syntax will get you every time,,,, Huh,,,!!!


Well Have Fun Huh!!!

MSI 845e mb 1 gb ram and a p4 2.4n running xp ,win 2000 advanced server and win 98 SE alot to learn and I know so little !!!!


0

Response Number 4
Name: chitti
Date: September 25, 2007 at 02:18:13 Pacific
Reply:

Thanks I found the other way - using awk
with FS as / and again concatenating all arguments with "\/" this when used in bash script worked perfectly.

Thanks,
Chitra


chitti


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


Sponsored links

Ads by Google


Results for: sed - how to append \ with /

hose apt how to retrieve with deb www.computing.net/answers/linux/hose-apt-how-to-retrieve-with-deb/16326.html

how to install Linux for dual boot? www.computing.net/answers/linux/how-to-install-linux-for-dual-boot/23424.html

How to synchronise with windows2k? www.computing.net/answers/linux/how-to-synchronise-with-windows2k/16068.html