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

delete all files older than 1 week 2

Status
Not open for further replies.

blueindian1

Programmer
Apr 24, 2001
150
US
Hello,

Total Unix newbie here....

I am in need of a command to include in a script that will delete all the files in a particular directory when they are more than 1 week old.

Any suggestions?

Thanks in advance :)
 
You may use the "find" command for this.

find <DirectoryName> -name '*' -mtime +7 -exec rm -f {} \;

Please read the manual pages of the &quot;find&quot; command before you use this.
 
thanks...worked like a charm, except i had to change '*' to *.*

could be a difference in shells? did this in the korn shell

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top