Register a domain and help support LQ
Go Back > Forums > Other *NIX Forums > Other *NIX
User Name
Other *NIX This forum is for the discussion of any UNIX platform that does not have its own forum. Examples would include HP-UX, IRIX, Darwin, Tru64 and OS X.


  Search this Thread
Old 04-17-2008, 07:45 AM   #1
LQ Newbie
Registered: Apr 2008
Posts: 1

Rep: Reputation: 0
Could not run SED command

I am using solrais 10 on sun sparc.

The following command executes successfully

echo c:/test.txt | sed -e 's/\//\\\//g'

But when i executes the following command

x=`echo c:/test.txt | sed -e 's/\//\\\//g'`

I get the following error

sed: command garbled: s/\//\\//g

Is there any way to avoid this error. I am using the Bash shell.
Old 04-17-2008, 07:54 AM   #2
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 13,142

Rep: Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262
Use a different separator - say ":"
Old 05-04-2008, 09:35 PM   #3
Registered: Apr 2008
Posts: 310

Rep: Reputation: 30

Using a different separator is the preferred way to do it. As you can see below, this will solve your problem, but it's really easy to get lost in all the onion-peeling involved with all the escapes

x=`echo c:/test.txt | sed -e 's/\//\\\\\//g'`

Best wishes,

Old 05-05-2008, 06:07 AM   #4
Senior Member
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
x=$(echo "c:/test.txt" | sed -e 's@/@//@g')


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
sed command help viveksnv Programming 3 02-26-2008 07:40 AM
sed command help jaredhanks Linux - General 4 08-15-2006 04:19 PM
sed command ancys Programming 3 08-05-2006 09:30 AM
sed command ancys Programming 5 08-03-2006 11:39 PM
sed command kwigibo Linux - General 3 04-21-2002 04:11 PM

All times are GMT -5. The time now is 09:41 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration