Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying files based on find results

Status
Not open for further replies.

MCubitt

Programmer
Mar 14, 2002
1,081
GB
I need to backup all initXXX.ora files (we have duplicates) which are in different locations...

I know from a find you can use the results to feed another command.. but am not sure how to do it.

Ie I want to

find / -name 'init$DBNAME.ora'

and PUX the result (to retain hierachy) to /backup

for each ocurrence.

I hope this is clear?




Applications Support
UK
 
Code:
# note - the following command is a single line

find /  -type f -name "init$DBNAME.ora" -exec pax -rw {} /backup \;

I added "-type f" to avoid ever copying a directory, and changed the quotes to double so that $DBNAME would be expanded.

Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

 
Thanks Rod, in fact I changed it further...
Code:
select 'find / -type f -name "init' || instance ||'.ora" -exec pax -rw {} &dir \;' from v$thread;
and
Code:
select 'find &dir -type f -name "init' || instance ||'.ora" -exec pax -rw {} / \;' from v$thread;

this resulted in the SQL script:
Code:
find / -type f -name "initIFSD.ora" -exec pax -rw {} /ifsdoc/kmbackuprestore \;
and
Code:
find /ifsdoc/kmbackuprestore -type f -name "initIFSD.ora" -exec pax -rw {} / \;

I think this'll work!!










Applications Support
UK
 
Oops, added host before the find which will help!




Applications Support
UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top