Ok so this happened recently when there was a requirement to delete all files in a Linux directory that were 30 days old.
The best I could do is to check the last modified date for each file in the folder in question and then go on deleting them individually but that would have been a nightmare
Below is how I did it.
There could be a better way out there, as I am not a Linux expert this is the best solution I can come up with.
The above should be read as “find all those files in /home/jaspreet/somefolder whose last modified time is more that 30 days and then execute rm on all of them”
Please note that we are using absolute path to the folder to find files in it.
Now this works very well for me.
You can extend this to say finding all the TXT files in that folder and then executing the rm command on that batch found.
I strongly recommend that before you do anything its a wise thing to just run find command and check the returned files are what you really would like to remove.
I hope this helps
Cheers





JC WordPress Coupon Revealer Plugin Pro License
Australian Street Names with City, State and Display Names only, Single Server License
Recent Comments