Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-09-2007, 09:10 PM   #1
Registered: Oct 2006
Posts: 75

Rep: Reputation: 15
About deleting a files

I got a mission. It's to delete some files in a folder that was created before in a specified date.

I only know to use ls -la to check files date.
But the problem is there are too much files and lots documents directory..

Is there a way to check the files date and delete them?

thx for help.
Old 01-09-2007, 10:54 PM   #2
Senior Member
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
Use find in conjunction with exec, e.g.

find . -mtime +5 -mtime -7 -exec rm -i {} \;
This will remove all files last modified between 5 & 7 days ago.

Note that I've specified the -i flag to rm to make it prompt before removing a file. This is always a good idea when doing magic with find + rm to make sure you only remove the files you want to remove. Remember, there's no undelete on the command line (alternatively you could mv the found files to another directory for later perusal/removal, e.g.:

find . -mtime +5 -mtime -7 -exec mv {} ~/files_for_deletion/ \;
See "man find" for more details about what you can do with find. it is a very powerful tool!


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
Deleting files rossi46 Mandriva 5 11-08-2006 08:15 AM
Deleting old files shiroh_1982 Linux - Newbie 2 06-21-2006 07:26 AM
Deleting files in C monil Programming 4 03-13-2005 10:33 AM
Deleting files! a_priebe47 Slackware 6 10-17-2004 09:58 PM
Deleting files ShakyJake Linux - Newbie 12 05-08-2003 03:07 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:34 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration