Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Nov 2004 10:19:39 +0100
From:      Dennis Koegel <amf@hobbit.neveragain.de>
To:        Mipam <mipam@ibb.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: /bin/rm: Argument list too long.
Message-ID:  <20041119091938.GA964@neveragain.de>
In-Reply-To: <Pine.BSO.4.56.0411190956490.18264@ux11.ltcm.net>
References:  <Pine.BSO.4.56.0411190956490.18264@ux11.ltcm.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041119091938.GA964>