Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sed with backslash

Status
Not open for further replies.

victorv

Vendor
Aug 20, 2002
862
IT
Hi,
I am not able to use sed with syntax :

echo $LINE | sed "s/str1/str2/g"

if str2 is a backslash .

------------------------------------

I have to translate a Unix path /home/mydir/a/b/c
in a DOS one as \home\mydir\a\b\c .

I can capture str1 = / (using "s/\// ) but when
I use \ or \\ to indicate the backslash in the replace part, the syntax become incorrect.

Thanks

 
Here's how to complete it at a shell prompt.

echo $LINE | sed "s#/#\\\#g"

You would need to play with your str values.

-glenn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top