For me the need to rename the files under unix is almost a frequent task,
like backup the set of unix files while some activity will overwrite the existing files or using the database creation template scripts to create another new database.
I use the following simple shell script to rename the files,
For example we have a set of files as follows,
/var/tmp/orainstall1.sql
/var/tmp/orainstall2.sql
/var/tmp/orainstall3.sql
/var/tmp/orainstall4.sql
/var/tmp/orainstall5.sql
and I want to rename them as
oracreate1.sql,
oracreate2.sql,
oracreate3.sql,
oracreate4.sql,
oracreate5.sql
I am listing the files under /var/tmp
$cd /var/tmp
$pwd
$/var/tmp
$ls ora*.sql
$orainstall1.sql
orainstall2.sql
orainstall3.sql
orainstall4.sql
orainstall5.sql
--script start here
$for file in orainstall*.sql;do
newfile=`echo $file | sed 's/install/create/'`
mv $file $newfile
done
--script end here
Checking the files for change
$pwd
/var/tmp
$ls ora*.sql
oracreate1.sql
oracreate2.sql
oracreate3.sql
oracreate4.sql
oracreate5.sql
$
Happy testing..
Showing posts with label Shell script. Show all posts
Showing posts with label Shell script. Show all posts
Saturday, September 1, 2007
Thursday, August 16, 2007
Reference for Shell Scripting
I am a subscriber to the newsletter from
oracle_tips@topica.email-publisher.com
for the last three years and used to get good and informative mails from them.
The following pdf document reference is the one I received recently and found very useful as a reference in my day to day Oracle DBA activities.I've even shared the same to many of my known Oracle DBAs and Unix administrators.Blogging here by giving the link if someone will find it useful.
http://www.dba-oracle.com/Shell-Script-sec.pdf
Source Donald K. Burleson
oracle_tips@topica.email-publisher.com
Happy reading..
oracle_tips@topica.email-publisher.com
for the last three years and used to get good and informative mails from them.
The following pdf document reference is the one I received recently and found very useful as a reference in my day to day Oracle DBA activities.I've even shared the same to many of my known Oracle DBAs and Unix administrators.Blogging here by giving the link if someone will find it useful.
http://www.dba-oracle.com/Shell-Script-sec.pdf
Source Donald K. Burleson
oracle_tips@topica.email-publisher.com
Happy reading..
Subscribe to:
Posts (Atom)