Problem with sed

Hi all,

i am writing a shell script to replace a variable using sed command.
The snippet is as follows:-

# to find the value of APPDIR
# APPDIR 's value needs to be changed
 x=`grep APPDIR /dir1/dir2/resp_cde.ats`

# the new value of APPDIR
new=/cd_e/fg/h

# to replace APPDIR with new value
sed "s#$x#$new#" ${LOC1}/resp_cde.ats > ${LOC1}/resp2.ats

Now the problem is the value is not getting replaced.
Instead the new file which is getting created has the same value as that of the old one.

Can any one please help me out regarding this problem.

Thanks,
Vikas

Is there any method by which I can replace the entire text without finding the pattern...???

I mean to say that:-
if i would like to replace
x=dfg/hjl
with
x=fgh/klo

then can I replace with contents of x without specifying x=dfg/hjl in sed command.

In simple terms I want to replace without giving the pattern.

The code of your first post should work, check the value of x first with an echo command.
If you can't get it work, post an example of the input file and the desired output.

Regards

Sorry with the slash:-

The actual path is like that of Windows folder structure:-
x=C:\Program Files\Cogny\cert

The value of this x needs to be changed.

Can you help me out in this case.

Quote the backslashes with a backslashes. For example, to replace x=C:\Program Files\Cogny\cert with x=C:\Mydir\cert:

sed 's/x=C:\\Program Files\\Cogny\\cert/x=C:\\Mydir\\cert/' file

Regards