[K12OSN] OT: Scripting Question

Dan Young dyoung at mesd.k12.or.us
Thu Nov 30 16:21:47 UTC 2006


Dan Young wrote:
> Calvin Dodge wrote:
>> On 11/30/06, Jim Kronebusch <jim at winonacotter.org> wrote:
>>> I hate to post another scripting question out here again, but you guys
>>> are so
>>> darn good it would be a shame not to :-)
>>>
>>> I have a folder full of files, I need a script that deletes any files
>>> in that
>>> folder that are more than 30 days old.  Sort of an automatic pruning. 
>>> I will
>> find /FOLDERNAME -type f -mtime +30 -exec rm -f {} ';'
> 
> Fun trivia: xargs is faster than -exec'ing on every file. It will delete
> the files together with one invocation of "rm" (or in optimally sized
> chunks if you're deleting _lots_ of files):
> 
> find /FOLDERNAME -type -f -mtime +30 -print0 | xargs -0 rm -f

Oops:

find /FOLDERNAME -type f -mtime +30 -print0 | xargs -0 rm -f

-- 
Dan Young <dyoung at mesd.k12.or.us>
Multnomah ESD - Technology Services
503-257-1562




More information about the K12OSN mailing list