I've noticed that one of our interface directories has a lot of old files, some of them were more than a year old. I checked it with our implementers and it turns out that we can delete all files that are older than 60 days. I decided to write a (tiny) shell script to purge all files older than 60 days and schedule it with crontab, this way I won't deal with it manually. I wrote a find command to identify and delete those files. I started with the following command:
It finds and deletes all files in directory /interface/inbound that are older than 60 days. After packing it in a shell script I got a request to delete "csv" files only. No problem... I added the "-name" to the find command:
All csv files in /interface/inbound that are older than 60 days will be deleted. But then, the request had changed, and I was asked to delete "*.xls" files further to "*.csv" files. At this point things went complicated for me since I'm not a shell script expert... I tried several things, like add another "-name" to the find command:
But no file was deleted. Couple of moments later I understood that I'm trying to find csv files which is also xls files... (logically incorrect of course). After struggling a liitle with the find command, I managed to make it works:
:-) Aviad |
Wednesday, June 10, 2009
Purge old files on Linux/Unix using “find” command
Posted by Aviad at 9:30 AM
Labels: Unix\Linux
Subscribe to:
Post Comments (Atom)
7 comments:
Hi,
You havedone really fablous blog. I found your blog very interesting and very informative for Oracle. I think your blog is great information source & I like your way of writing and explaining the topics.i found the other related to this.
Regards
oracle fussion middleware
Hi
You have a fabulous blog.I felt your blog very interesting and very informative for Oracle Applications. I think your blog is great information source & I like your way of writing and explaining the topics.i found other too
regards
oracle fussion middleware
Nice commands on Linux/Unix.
i want to know that what is difference between LINUX AND UNIX ?
are they help full in any app development ?
can you please tell how to convert excel into csv file in unix os.
Thanks,
Vijay
find command
Thanks for sharing the information
Oracle Certification Program
Nice article about JRE upgrade
I have been trying the upgrade in my EBS env. It is really simple but some user may face issue
Post a Comment