LinuxQuestions.org
Review your favorite Linux distribution.
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 02-16-2012, 04:26 AM   #1
SparkyL
LQ Newbie
 
Registered: Feb 2012
Location: South Africa, Gauteng, Johannesburg
Posts: 1

Rep: Reputation: Disabled
list then delete files in a directory with a specific date


I have a directory with files. I want to list all the files for a specific date then delete them... How do i go about doing this...?
 
Old 02-16-2012, 06:04 AM   #2
vishnu_sreekumar
Member
 
Registered: Jan 2006
Location: India
Distribution: Ubuntu, RHEL, Debian
Posts: 49

Rep: Reputation: 20
If my knowledge is correct, Linux filesystems doesn't store creation time. You can use -mtime (modification time), -atime (access time), -ctime (change time) flags of find command combined with the -exec flag to delete the files. A sample command to delete the files in a directory /testdir which were changed 2 days before would be
Quote:
find /testdir -type f -ctime 2 -exec rm -f {} \;
 
  


Reply


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
Delete/move/copy files of specific date imsajjadali Red Hat 26 11-08-2013 12:34 AM
[SOLVED] List specific files and delete results niiiro Programming 2 07-08-2011 10:08 AM
Delete all files of certain date. fatz2000 Programming 2 12-22-2009 10:06 AM
ow do I delete all files which were created on a specific date marsguy Linux - General 9 08-21-2007 09:15 AM
Copying files from a specific date dman65 Linux - Software 3 09-22-2003 11:16 AM


All times are GMT -5. The time now is 07:08 PM.

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