sed command not running


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed command not running
# 1  
Old 04-17-2008
sed command not running

I am using solrais 10 on sun sparc.

The following command executes successfully
Code:
echo c:/test.txt | sed -e 's/\//\\\//g'

But when i executes the following command
Code:
x=`echo c:/test.txt | sed -e 's/\//\\\//g'`

I get the following error
Code:
sed: command garbled: s/\//\\//g

Is there any way to avoid this error. I am using the Bash shell.

Last edited by Yogesh Sawant; 04-17-2008 at 10:05 AM.. Reason: added code tags
# 2  
Old 04-17-2008
one way:

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

#  echo $x
c:\/test.txt


Last edited by Tytalus; 04-17-2008 at 10:23 AM.. Reason: copy / paste :-)
# 3  
Old 04-17-2008
what is it that you're trying to achieve?
# 4  
Old 04-18-2008
thanks for reply

Thanks all of you for helping me.

>what is it that you're trying to achieve?

Actually, i am to pass the output of this command to SED to replace a variable PATH with the output of this command.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Another one line command where I'd like to determine if Ubuntu or Red Hat when running command

Hello Forum, I'm making very good progress on my report thanks to the very helpful people on this forum. I've been able to successfully create my report for my Red Hat servers. But I do have a few ubuntu servers in the mix and I'd like to capture some data from them when an ssh connection is... (8 Replies)
Discussion started by: greavette
8 Replies

2. Shell Programming and Scripting

GNU sed running on Mac

Super basic question. I installed sed GNU on a MAC running High Sierra. However, when I run sed '1i>sometext, I get the following error: sed: 1: "1isometext"; command i expects \ followed by text I have added the \ with no success. Is there anyway I can run sed and awk on MAC in the... (5 Replies)
Discussion started by: Xterra
5 Replies

3. AIX

I'm facing problem with rpm command, when running the command and appears this error:

exec(): 0509-036 Cannot load program /usr/opt/freeware/bin/rpm because of the following errors: 0509-022 Cannot load module /opt/freeware/lib/libintl.a(libintl.so.1). 0509-150 Dependent module /opt/freeware/lib/libiconv.a(shr4.o) could not be loaded. 0509-152 Member... (4 Replies)
Discussion started by: Ohmkar
4 Replies

4. Shell Programming and Scripting

Command to check only Autosys running jobs with autorep like command

Hi, Is there any specific command to use to check only say Running jobs via autorep or similar command for Autosys? (0 Replies)
Discussion started by: sidnow
0 Replies

5. Shell Programming and Scripting

Running sed from a script query

Hello! I'm trying to run this code to print the body of an html document (all text in between <body> and </body>) from a script but am unsure how to call it from the command line interface. /<body>/,/<\/body>/ 1s/.*<body>// $s/<\/body>.*//p I have tried to call it using this: sed... (6 Replies)
Discussion started by: bgnersoon2be#1
6 Replies

6. UNIX for Dummies Questions & Answers

Running set options from the command line and bash command

I'm reading about debugging aids in bash and have come across the set command. It says in my little book that an addition to typing set you can also use them "on the command line when running a script..." and it lists this in a small table: set -o option Command Line... (5 Replies)
Discussion started by: Straitsfan
5 Replies

7. Shell Programming and Scripting

Running sed commands

Hello I need to run some sed commands but it involves "/" in the substitute or delete, any ideas how I get round the problem. Example: cat file1.txt | sed -e '/</Header>/d' > file2.txt This errors due to the forward slash before the Header text. Thanks (3 Replies)
Discussion started by: Dolph
3 Replies

8. Shell Programming and Scripting

Loop with sed command to replace line with sed command in it

Okay, title is kind of confusion, but basically, I have a lot of scripts on a server that I need to replace a ps command, however, the new ps command I'm trying to replace the current one with pipes to sed at one point. So now I am attempting to create another script that replaces that line. ... (1 Reply)
Discussion started by: cbo0485
1 Replies

9. SuSE

inconsistent ls command display at the command prompt & running as a cron job

Sir, I using the following commands in a file (part of a bigger script): #!/bin/bash cd /opt/oracle/bin ls -lt | tail -1 | awk '{print $6}' >> /tmp/ramb.out If I run this from the command prompt the result is: 2007-05-16 if I run it as a cron job then... (5 Replies)
Discussion started by: rajranibl
5 Replies

10. Shell Programming and Scripting

Running Sed on a file.

I'm taking in an arguement thats sorted in $file. The $file contains a file name like file1.txt or something all files are in the same directory as the script.. Can I run sed on the file ? I was thinking of using something like more file.txt | sed "s/http//" Something like that is... (2 Replies)
Discussion started by: Paulw0t
2 Replies
Login or Register to Ask a Question