[LUAU] How do you delete over 500,000 files in a directory
Jim Thompson
jim at netgate.com
Thu Nov 3 16:37:13 PST 2005
Hawaii Linux Institute wrote:
> 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'
>>
>> I think someone else in this situation had a method of switching to
>> another
>> shell, bash is default.
>>
>> All the files start with mgetty. I would like to prserve the other
>> files in
>> the directory and the directories below /var/log
>>
>> Anyone have any ideas?
>
> There is nothing wrong with bash. The problem is, bash will evaluate
> the wildcard first and then turn your 500,000 files into a huge number
> of arguments for the rm command (thus the "too many arguments" error)
>
> The easiest way is do this one at a time, & I am sure everyone here
> knows how to do this. For example:
>
> for i in m*; do rm m*; done
still requires bash to glob all 500,000 files. Fails for the same reaons.
Jim
More information about the LUAU
mailing list