Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 07 Feb 2012 22:14:56 +0000
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        freebsd-questions@freebsd.org
Subject:   Re: 'rm' Can not delete files
Message-ID:  <4F31A260.20109@infracaninophile.co.uk>
In-Reply-To: <1237723287.20120207235924@yandex.ru>
References:  <1237723287.20120207235924@yandex.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig3CE09D16F9827880D8F947D7
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.
>=20
>=20
> in this directory about 25000 files,
> but actually there is only one argument to rm it is '*' sign.
>=20
> Why rm get list of all files in directore instead of deleting one by on=
e?

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

	Cheers,

	Matthew

--=20
Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
JID: matthew@infracaninophile.co.uk               Kent, CT11 9PW


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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8xomAACgkQ8Mjk52CukIyhpACfXBWFEK99yOgNbm4Dxce8jvYx
xiQAnA21b5IeFG5j4DgJ4j5IXHINJcDV
=qLjv
-----END PGP SIGNATURE-----

--------------enig3CE09D16F9827880D8F947D7--



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