[LUAU] How do you delete over 500,000 files in a directory
Bully
bully at hawaii.rr.com
Thu Nov 3 19:56:14 PST 2005
Jim Thompson wrote:
> Clifton Royston wrote:
>
>> On Thu, Nov 03, 2005 at 09:23:54AM -1000, Matt Darnell wrote:
>>
>>
>>> Aloha,
>>>
>>> We have a box with over 500,000 files in a direcotry. If I try 'rm
>>> m*' I get
>>> an error, something like 'too many arguments'
>>>
>>
>> ...
>>
>>
>>> All the files start with mgetty. I would like to prserve the other
>>> files in
>>> the directory and the directories below /var/log
>>>
>>
>>
>> ls | grep '^mgetty' | perl -nle 'unlink;'
>>
>> find . -name 'mgetty*' -maxdepth 1 -print | perl -nle 'unlink;'
>>
>> find . -name 'mgetty*' -maxdepth 1 -print | xargs rm
>>
>> ... and numerous variations you can probably think of now that you've
>> got the idea. Just avoid anything which requires the shell to do
>> globbing and you'll be fine.
>>
>>
> or cut down on the amount of globbing that the shell does in any one
> pass.
> If all the files end in a number, (and the numbers are well-distributed)
>
> #!/bin/bash
> i="0"
> while [ $i -le 9 ]
> do
> echo mgetty*$i | xargs rm -f
> i=$[$i+1]
> done
>
> _______________________________________________
> LUAU at lists.hosef.org mailing list
> http://lists.hosef.org/cgi-bin/mailman/listinfo/luau
>
>
>
> see how simple that was? DUH!!! :) You're KILLIN' ME Jim!!! : )
More information about the LUAU
mailing list