Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Dan's handy perl script
Hi,
I found a useful perl command which comes in handy.
Often I use it when I install an Oracle database using an existing tree of Oracle software rather than from a cdrom. I refer to this method as a "manual install".
I started using this method when Oracle released 8.1.6.
The reason for this is that after 8.1.6, I found that some of the sql scripts under $ORACLE_HOME have $ORACLE_HOME hard-coded into them.
So, suppose I have an existing database which was installed via cdrom and has this:
ORACLE_HOME=/oracle/app/oracle/product/BIKLE817
At this point I could tar-up ORACLE_HOME and copy it to another host.
Then suppose I unpack it here:
ORACLE_HOME=/oracle/app/oracle/product/SMITH817
Now is when my perl command comes into use:
cd /oracle/app/oracle/product/SMITH817
/bin/find . -type f -print|xargs /bin/grep -l BIKLE817|xargs /bin/perl -e "s/BIKLE817/SMITH817/g" -p -i.bak
The above perl command will find every file which contains the string: BIKLE817 It will edit each file and replace BIKLE817 with SMITH817.
All the files which contained BIKLE817 will be renamed with a .bak at the end of each file name.
If we are confident we no longer need the .bak files, we could delete them with this command:
/bin/find . -name '*.bak' -type f -print|xargs /bin/grep -l BIKLE817|xargs /bin/rm
I have more demos on my site.