Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 07 Feb 2012 22:14:56 +0000
From:      Matthew Seaman <>
Subject:   Re: 'rm' Can not delete files
Message-ID:  <>
In-Reply-To: <>
References:  <>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
Content-Type: text/plain; charset=windows-1251
Content-Transfer-Encoding: quoted-printable

On 07/02/2012 21:59, =CA=EE=ED=FC=EA=EE=E2 =C5=E2=E3=E5=ED=E8=E9 wrote:
> # rm *
> /bin/rm: Argument list too long.
> in this directory about 25000 files,
> but actually there is only one argument to rm it is '*' sign.
> Why rm get list of all files in directore instead of deleting one by on=

It's the shell that expands wild cards, and it will attempt to fork and
exec rm(1) with an arg list of all matching files. rm(1) itself has no
concept of wildcards -- it expects a list of filenames.

As you have discovered, it is very easy to overload the argument list.
There are many ways around this, but one of the best ones is to use
xargs(1). eg:

	% ls -1 | xargs rm



Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP:     Ramsgate
JID:               Kent, CT11 9PW

Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
Comment: Using GnuPG with Mozilla -



Want to link to this message? Use this URL: <>