LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


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

Rep: Reputation: 15
About deleting a files


Hi.
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
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

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

Code:
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.:

Code:
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!
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:01 AM.

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