Shell script to change a value

I have a shell script that has following entry.

MEM_ARGS="-Xms256m -Xmx512m"
export MEM_ARGS

if [ "${JAVA_VENDOR}" = "Sun" ] ; then
if [ "${PRODUCTION_MODE}" = "" ] ; then
MEM_DEV_ARGS="-XX:CompileThreshold=8000 -XX:PermSize=48m "
export MEM_DEV_ARGS
fi
fi

# Had to have a separate test here BECAUSE of immediate variable expansion on windows

if [ "${JAVA_VENDOR}" = "Sun" ] ; then
MEM_ARGS="${MEM_ARGS} ${MEM_DEV_ARGS} -XX:MaxPermSize=512m"
export MEM_ARGS
fi

if [ "${JAVA_VENDOR}" = "HP" ] ; then
MEM_ARGS="${MEM_ARGS} -XX:MaxPermSize=128m"
export MEM_ARGS
fi

I want to change the line MEM_ARGS="-Xms256m -Xmx512m" to new value lets say MEM_ARGS="-Xms512m -Xmx1024m" . The intention is tha twhetever the value to be given it should go and set Xms and Xmx values.The problem here is that I can't find for word MEM_ARGS= and replace then becuase MEM_ARGS= is existing multiple places. So probably I need to search for "MEM_ARGS="-Xms" in this file and then replace the value that I want. Can you please suggest the best possible commands?

Thanks in advance,
Rijesh.

To more about the problem

I could use cat setDomainEnv.sh | sed -e 's/MEM_ARGS="-Xms.*/MEM_ARGS="-Xms=256m Xmx=1024m"/' > setDomainEnv.sh_tmp , where as I want to the variable in sed. For example

replaceString="-Xms=${JVM_MIN} -Xmx=${JVM_MAX}" and assume JVM_MIN and JVM_MAX is being set already.

cat setDomainEnv.sh | sed -e 's/MEM_ARGS="-Xms.*/MEM_ARGS=${replaceString}/' > setDomainEnv.sh_tmp

This will not replace value ${replaceString} inside sed. Sed require double quote instead of single quotes to get variable replaced. However my string contains replaceString="-Xms=${JVM_MIN} -Xmx=${JVM_MAX}", so the below simply will not work.

cat setDomainEnv.sh | sed -e "s/MEM_ARGS="-Xms.*/MEM_ARGS=${replaceString}/" > setDomainEnv.sh_tmp

Please help on this.

Can u Pls Post the input file content and output ur expecting.

cat setDomainEnv.sh | sed "s/\(MEM.*Xms\)[0-9][0-9]*\(m -Xmx\)[0-9][0-9]*\(m\"\)/\1$JVM_MIN\2$JVM_MAX\3/g"

cheers,
Devaraj Takhellambam