Problem with sed

Hi,

I facing some problem while doing sed .
I have simple script.

#!/bin/sh
set -x
set -v
Test1=""

sed        -e s/dbccons_sparc/dbccons_linux/ \
              -e s/\${SOLARISMACH}/${Test1}/ \
              -e  s+'\"[ \t]*<<'+' \t<<'+ \
              -e s/\"\${DBCCONS}/\${DBCCONS}/ \
              -e  s+'\"[ \t]*\\'+' \t\\'+ \
              -e  s/rsh/${Test1}/ test.res > test.output

its executing fine but when I edit that script without any change and then saving it and compiling its throwing error.

+ set -v
Test1=""
+ Test1=

sed        -e s/dbccons_sparc/dbccons_linux/ \
              -e s/\${SOLARISMACH}/${Test1}/ \
              -e  s+'\"[ \t]*<<'+' \t<<'+ \
              -e s/\"\${DBCCONS}/\${DBCCONS}/ \
              -e  s+'\"[ \t]*\\'+' \t\\'+ \
+ sed -e s/dbccons_sparc/dbccons_linux/ -e 's/${SOLARISMACH}//' -e 's+\"[ \t]*<<+ \t<<+' -e 's/"${DBCCONS}/${DBCCONS}/' -e 's+\"[ \t]*\\+ \t\\+' ' '
sed: can't read  : No such file or directory
              -e  s/rsh/${Test1}/ test.res > test.output
+ -e s/rsh// test.res
./sample.sh: line 11: -e: command not found

Not getting where is problem in my script..

please help.

thanks,
Bhrat kapoor

---------- Post updated at 06:41 PM ---------- Previous update was at 06:33 PM ----------

Okay ..Please help on this

---------- Post updated at 06:55 PM ---------- Previous update was at 06:41 PM ----------

Same problem :

#!/bin/sh
sed        -e s/dbccons_sparc/dbccons_linux/ \
              -e  s/rsh/no/ test1.res > test1.output

test1.res contain :
rsh dbccons_sparc

but when I am just editing without any changes its throwing error.

+ set -v

sed        -e s/dbccons_sparc/dbccons_linux/ \
+ sed -e s/dbccons_sparc/dbccons_linux/ ' '
sed: can't read  : No such file or directory
              -e  s/rsh/no/ test1.res > test1.output
+ -e s/rsh/no/ test1.res
./sample1.sh: line 6: -e: command not found

Don't use -e and quote your sed commands. Sed is a independent from a shell and its language doesn't have anything common with shell language:

sed  's/dbccons_sparc/dbccons_linux/
s/rsh/no/' test1.res > test1.output

If I need to do some opration like : s+'\"[ \t]*\\'+' \t\\'+
how to keep this in this code.

sed  's/dbccons_sparc/dbccons_linux/
s/rsh/no/' test1.res > test1.output

Homework and coursework questions can only be posted in the homework forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

Thank You.

The UNIX and Linux Forums.