Did you know LQ has a Linux Hardware Compatibility List?
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, 08: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, 08:54 AM   #2
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,561

Rep: Reputation: 1085Reputation: 1085Reputation: 1085Reputation: 1085Reputation: 1085Reputation: 1085Reputation: 1085Reputation: 1085
Use a different separator - say ":"
Old 05-04-2008, 10: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, 07:07 AM   #4
Senior Member
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,245
Blog Entries: 16

Rep: Reputation: 233Reputation: 233Reputation: 233
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 08:40 AM
sed command help jaredhanks Linux - General 4 08-15-2006 05:19 PM
sed command ancys Programming 3 08-05-2006 10:30 AM
sed command ancys Programming 5 08-04-2006 12:39 AM
sed command kwigibo Linux - General 3 04-21-2002 05:11 PM

All times are GMT -5. The time now is 12:21 AM.

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 @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration