Register
It is currently Wed Apr 23, 2014 8:50 pm

Using sed to replace a string containing \


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Wed Nov 19, 2008 5:49 am   

Joined: Fri Sep 26, 2008 7:58 am
Posts: 10
Is it possible to replace a string using sed if that string conatins the character \ ?

I mean the \ character has meaning for sed but is there a way for it to pass that as part of the string and not a special character?

To further clarify:

Code:
sed 's/\,/\/g'


Is basically what I want to do, but it throws this:

Code:
sed: -e expression #1, char 8: unterminated `s' command


I mean OK fair enough I knew that the above command wasn't going to work, but how do I get something like that to work?


Top
 Profile  
 PostPosted: Wed Nov 19, 2008 8:00 am   

Joined: Fri Sep 26, 2008 7:58 am
Posts: 10
Sorted it out. No worries.

sed 's/\\,/\/g'

thanks anyway though.


Top
 Profile  
 PostPosted: Wed Nov 19, 2008 3:24 pm   

Joined: Mon Nov 17, 2008 7:25 am
Posts: 221
escape is the name of the game ;)

\\ will produce a \ since you escape it :)

Best regards
Fredrik Eriksson


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP