Problem in using sed commnad in bash program.
hi All,
here is my problem I try to use "sed" command as followig but I got error! path=(`pwd`) . . sed 's/home\/aruna\/WORK\/GUI_test\/testharness/($path)/g' run.tcl >> run1.tcl I cann't figure out what is the problem with this. When I print path on screen it was having a correct value. I think the problem is that path is having "/" characters inside it. can you please give me a solution for this? Thanks, Aruna. |
cat run.tcl | sed s/'home\/aruna\/WORK\/GUI_test\/testharness'/($path)/ >> run1.tcl
|
Code:
path=(`pwd`) that should be Code:
path="`pwd`" Code:
sed s@home/aruna/WORK/GUI_test/testharness@"${path}"@g run.tcl >> run1.tcl |
hi,
It's not working and following is the error message /home/aruna/WORK/GUI_test/testharness ./rtest: line 46: syntax error near unexpected token `(' ./rtest: line 46: ` cat run.tcl | sed s/'home\/aruna\/WORK\/GUI_test\/testharness'/($path)/ >> run1.tcl' Thanks, Aruna. |
Hi,
Below is a code that should work fine. The problem is with the "pwd" command, because it returns the value something like "/home/arun". Which contains "/" slashes and you were passing it as it to sed without using the "\" slashes. So, you first need to convert "/" slashes to "\/": path=$(pwd) path=$(echo $path | sed 's/\//\\\//g') . . . sed 's/home\/aruna\/WORK\/GUI_test\/testharness/$path/g' run.tcl >> run1.tcl Regards, --Talha |
Hi,
Thanks very much for the help and the lesson. It is working fine. Regards, Aruna. |
All times are GMT -5. The time now is 08:51 AM. |