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

Remove files older than 7 days

Status
Not open for further replies.

tcol

Programmer
Jun 27, 2001
2
US
I need to remove files in a directory which are older than 7 days from the current date. Can someone please provide an example of how to do this using awk (or kornshell).
Thanks
 
Hi tcol,

Here are two find commands to do this in the
current directory:


# asks if O.K. to delete file ( safest method but slow )

find . -atime +7 -ok rm -f {} \;

# deletes file automatically ( potentially dangerous! )

find . -atime +7 -exec rm -f {} \;

# Hope this helps you!


flogrr
flogr@yahoo.com

 
yeah - that's right. The only thing is the
_vague_ definition of "older".

#define older accessTime
#define older creationTime
#define older statusChangeTime
#define older dataModifiedTime

or some kind of the combinations of the some/all
of the above.

vlad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top