(I bolded and underline the command so you can see what I am doing)
I get no match, no replacement, just a prompt >
I tested replacing the line from the = sign to the end of the line with the above command and it works, but I can not use that because I have 5 lines to replace in script with each having excactly the same 2nd half and a different 2nd for each of the 5 lines. The first part of each line starts with $ENV{', and single quote is part that does not work. If I had lines that did not have the single quote in the line, the above command would work (without the single quote of course).
# Lets print the file contents
C:\Users\Ninz\Desktop>type a.txt
This is a fake file
$ENV{'ORACLE_HOME'} = "/home/oracle/product/10.1.0/db_1" ;
this is the last line
# using windows , using different separator "|" instead of "/" so that you dont have to escape every "/" in path
# Adding "-i.bak" because in windows it throws error if you try to modify file without taking backup
C:\Users\Ninz\Desktop>perl -pi.bak -e "s|\$ENV{'ORACLE_HOME'} \= \"/home/oracle/
product/10.1.0/db_1\"| \$ENV{'ORACLE_HOME'} \= \"/opt/app/any/other/path\"|" a.txt
C:\Users\Ninz\Desktop>type a.txt
This is a fake file
$ENV{'ORACLE_HOME'} = "/opt/app/any/other/path" ;
this is the last line
C:\Users\Ninz\Desktop>
The 200 perl scripts are on a Unix/Linux server, so I can't use a '|' and I have to escape '/' in the path. But that is not the problem. I can escape '/' in the path and and escape the '$' and escape the '{' and it will match and replace the text. The problem is the single quote before and after ORACLE_HOME. Does anyone know how to match and replace a single quote in a line of text in a file?
@JC9672 : Why cant you use different separator ?? Its valid and its not Platform specific.
I have copied below example on RH4 box and tried again, it worked without any modification ( If something works on windows then it should work on *nix without any problem )
Checking file contents, there are quotes before ORACLE_HOME
$ > cat a.pl
This is a fake file
$ENV{'ORACLE_HOME'} = "/home/oracle/product/10.1.0/db_1" ;
this is the last line
$ >
I copied and pasted your command and it did not work. I even copied your script and it did not work. I did not get any error message, but no replacement either. I am using a Red Hat box verison 8 or 9. I not sure which. Also my Perl version is 5.12.3. Maybe that is why it did not work.