Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Dan's handy perl script

Dan's handy perl script

From: Dan Bikle <dbikle_at_rahul.net>
Date: 18 Dec 2001 21:13:26 GMT
Message-ID: <9vobhm$s2e$1@samba.rahul.net>

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.



Daniel B. Bikle/Independent Oracle Consultant bikle_at_bikle.com | 650/941-6276 | P.O. BOX AG LOS ALTOS CA 94023 http://www.bikle.com
Received on Tue Dec 18 2001 - 15:13:26 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US