Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 01-25-2006, 08:03 PM   #1
Registered: Sep 2005
Posts: 855

Rep: Reputation: 30
Automatically delete old files


I'm doing backup of files. What I want to do is I want to delete files older than 5 days on a directory. Can someone give me script to do this? Or at least the syntax in rm command? Thanks.
Old 01-25-2006, 08:15 PM   #2
LQ Guru
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 273Reputation: 273Reputation: 273
try rm -i `find /thedirectory/goes/here -type f -atime 5`. Note that the ` is the apostrophe on the ~ key of a standard US keyboard.

man find for the other options like -ctime (last status changed n*24 hours ago) or -mtime (last modified n*24 hours ago) instead of -atime (last accessed n*24 hours ago)...

Last edited by pljvaldez; 01-25-2006 at 08:17 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to delete files that won't delete? di11rod Linux - Security 7 10-19-2005 10:14 PM
how do you delete files? otoomet Linux - General 6 11-12-2004 05:06 AM
Delete Files imsajjadali Red Hat 15 07-23-2004 02:12 PM
Editior automatically delete content between lines dnla Linux - Newbie 2 10-21-2003 05:57 PM
How to delete the destination files while the source files deleted in cp -u ? myunicom Linux - General 4 09-26-2003 02:13 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:47 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration