So your command would look like to delete 10 years old files:
Enjoy..
Of course, if you can't multiply 10 * 365 in your head but you're using a standards conforming shell (such as bash or ksh), you could also use:
without needing to start us another process to run bc.
Since it is quite possible that this find will remove applications, libraries, and data files that are used every day but haven't changed in the last decade; be sure that you only run something like this after you have made a backup of every file that might be affected... (I would strongly suggest running this with "-exec rm {} \;" replaced by "-print" first as a sanity check on what will be removed!)
Are you really worried about 2 or 3 days when you're going back a decade?
Last edited by Don Cragun; 07-08-2013 at 03:27 PM..
Reason: Fix typo.
I am not worried for 2 or 3 days. It was just a requirement and so I asked. I have already done 3650 but thought to ask if there is anything similar considering years. I use an ETL tool and coding in that would take lot of time and we can put one line unix commands easily so gave it a try. Who knows how things will be after 10 years. I asked just for my knowledge
With a POSIX conforming shell (such as bash or ksh), you could try:
to look for files 10 or more years old to the current minute. (Note that if you run it on February 29 in a leap year, the date given 10 years earlier will be on March 1.) If this does what you want, you can change the "ls -l" to "rm".
This will even work on a Solaris system where the date utility doesn't have a -d option.
Hi,
I need a command for deleting all the compress files *.Z that are older than the current date - 5 days. Basically I have a directory where daily I meet some back up files and I want to remove automatically the ones 5 days (or more) older than the current date. How can I write a 'rm' command... (1 Reply)
Hi All,
I am using below code to delete files older than 2 days. In case if there are no files, I should log an error saying no files to delete.
Please let me know, How I can achive this.
find /path/*.xml -mtime +2
Thanks and Regards
Nagaraja. (3 Replies)
I have to retain only 1 day files in my system an I have to delete all the other files which are older than 24 hrs. Please let me know the option I have to give in the find -mtime command. (3 Replies)
Hello - I have a folder that contains files from 2003 till 2010. I am trying to figure out a command that would seperate each years file and show me a count?
Even if i can find a command that would give me year by year count, thats good enough too.
Thanks (8 Replies)
i have to delete files which are older than 15 days or more except the ones in the directory Current and also *.sh files
i have found the command for files 15 days or more older
find . -type f -mtime +15 -exec ls -ltr {} \;
but how to implement the logic to avoid directory Current and also... (3 Replies)
Hi all,
i have a simple question that i want to find out the 30 minutes older files and delete those files from the particular location(Folder)
Generally for this purpose used to retreive the files with "atime" command
For example: find and delete the 2 days older log files use this below... (2 Replies)