Jan 18, 2006 #1 tnodine IS-IT--Management Joined Dec 12, 2001 Messages 21 Location US can someone please let me know a command in unix to remove/delete files in specific date range? for instance, I want to delete all files in a directory with the year of 2003. or maybe all files for 2004 between Jan and May? thanks for the help. T.
can someone please let me know a command in unix to remove/delete files in specific date range? for instance, I want to delete all files in a directory with the year of 2003. or maybe all files for 2004 between Jan and May? thanks for the help. T.
Jan 18, 2006 #2 stefanwagner Programmer Joined Oct 19, 2003 Messages 2,373 Location DE Code: touch -d'2004-01-01 00:00:00' 2004-Jan touch -d'2004-05-31 23:59:59' 2004-May find /some/dir -newer 2004-Jan -not -newer 2004-May -exec ls -la {} \; instead ls -la use rm, but performing a test before isn't a bad idea. seeking a job as java-programmer in Berlin: http://home.arcor.de/hirnstrom/bewerbung Upvote 0 Downvote
Code: touch -d'2004-01-01 00:00:00' 2004-Jan touch -d'2004-05-31 23:59:59' 2004-May find /some/dir -newer 2004-Jan -not -newer 2004-May -exec ls -la {} \; instead ls -la use rm, but performing a test before isn't a bad idea. seeking a job as java-programmer in Berlin: http://home.arcor.de/hirnstrom/bewerbung
Jan 19, 2006 1 #3 Ogzilal MIS Joined Oct 9, 2003 Messages 280 Location FR Hi, You can also use find with -mtime switch ( modified time ) to list the files not modified since 365 days Code: find /somewhere -mtime +365 -exec ls -al {} \; to remove this listed files, replace "exec ls -l" by "exec rm" Upvote 0 Downvote
Hi, You can also use find with -mtime switch ( modified time ) to list the files not modified since 365 days Code: find /somewhere -mtime +365 -exec ls -al {} \; to remove this listed files, replace "exec ls -l" by "exec rm"
Jan 19, 2006 #4 columb IS-IT--Management Joined Feb 5, 2004 Messages 1,231 Location EU aau tnodine requires a range of dates. I believe you could use Code: find /some/dir -mtime +365 -mtime -700 but stefanwagner's suggestion is far more user friendly. Can you tell me the relevant number of days to put for Jan -> May 2004? Columb Healy Upvote 0 Downvote
aau tnodine requires a range of dates. I believe you could use Code: find /some/dir -mtime +365 -mtime -700 but stefanwagner's suggestion is far more user friendly. Can you tell me the relevant number of days to put for Jan -> May 2004? Columb Healy
Jan 19, 2006 Thread starter #5 tnodine IS-IT--Management Joined Dec 12, 2001 Messages 21 Location US Basically, what I want to do is remove all the files that return as result of : ls -la | grep "2003 " This will give me all files in 2003. Thanks, T. Upvote 0 Downvote
Basically, what I want to do is remove all the files that return as result of : ls -la | grep "2003 " This will give me all files in 2003. Thanks, T.
Jan 19, 2006 Thread starter #6 tnodine IS-IT--Management Joined Dec 12, 2001 Messages 21 Location US Nevermind my last post.. I beleive I was able to take care of it using aau's suggestion. Thanks for everyones help! Upvote 0 Downvote
Nevermind my last post.. I beleive I was able to take care of it using aau's suggestion. Thanks for everyones help!