How to escape $ character on unix
807605Sep 28 2007 — edited Sep 28 2007Hi:
I have to subsitute the following line in a file with a value -
${myhome.mydir}/newloc/newfile;
Now, I have the value to subsitute the above and i use the line.replaceFirst(find_string, replace_string) command to do the subsitution. In that
find_string = "\\$\\{myhome.mydir}\\/newloc\\/newfile;
replace_string=C: + directory_separator + Temp + directory_separator + File1;
The subsitution works fine on windows but chokes at the $ subsitution on LINUX. ie if i remove the $ from ${myhome.mydir}/newloc/newfile, and then redefine the find_string in my java code to be "\\{myhome.mydir}\\/newloc\\/newfile; then the subsitution happens.
But I cannot change the original line.
Please let me know what I need to change in my find_string syntax so i could run replace_first fine on both windows and *nix platforms?
Thanks a lot!