'rm' Can not delete files
Matthew Seaman
m.seaman at infracaninophile.co.uk
Tue Feb 7 22:15:01 UTC 2012
On 07/02/2012 21:59, Коньков Евгений 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 one?
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
--
Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard
Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate
JID: matthew at infracaninophile.co.uk Kent, CT11 9PW
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 267 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20120207/72448fdc/signature.pgp
More information about the freebsd-questions
mailing list