/bin/rm: Argument list too long.

Dennis Koegel amf at hobbit.neveragain.de
Fri Nov 19 01:19:41 PST 2004


On Fri, Nov 19, 2004 at 09:58:40AM +0100, Mipam wrote:
> I tried to delete all files from a dir, however I got this message:
> /bin/rm: Argument list too long.

You probably did "rm *", and * expanded to too many files.

One way is to simply remove the directory completely (rm -r /foo/bar),
but this also removes all subdirectories.

Other way would be to use find and xargs; in this example for only the
files in one specific directory and no subdirectories (and no symlinks,
that is):

find /foo/bar -type f -maxdepth 1 | xargs rm -n100

... where -n controls the number of arguments passed per one execution
of rm.

HTH,
- D.


More information about the freebsd-questions mailing list