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: matt...@infracaninophile.co.uk               Kent, CT11 9PW

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to