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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autodelete script problem

Status
Not open for further replies.

Midrange

Vendor
Aug 28, 2002
135
SG
Hi there I have a problem after running my script. Please check my script below:

find /backup/data -name '*' -type d -mtime +7 -exec rm -r {} \; 1>/dev/null 2>&1

find /backup/data1 -name '*' -type d -mtime +7 -exec rm -r {} \; 1>/dev/null 2>&1


my aim is to delete only the directory under the data and data1. But after running the script the data and data was also deleted. I hope you can help me...

thanks..
 
Midrange:

Two ways:

1) touch /backup/data and /backup/data1. find ignores these directory objects

2) cd to /backup/data and /backup/data1 and then perform your find.

1) is the best choice in my opinion.

also, you probably don't need -name "*". You're already telling find to only delete the eligible directories.

Regards,

Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top