[LUAU] How do you delete over 500,000 files in a directory
Hawaii Linux Institute
wp at HawaiiLinux.us
Thu Nov 3 14:57:56 PST 2005
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
(This is a very powerful command; make sure you are in the right folder
and have a proper back b/f doing it.) Wayne
More information about the LUAU
mailing list