Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 07 Feb 2012 14:06:12 -0800
From: (Randal L. Schwartz)
To:        =?utf-8?B?0JrQvtC90YzQutC+0LIg0JXQstCz0LXQvdC40Lk=?= <>
Subject:   Re: 'rm' Can not delete files
Message-ID:  <>
In-Reply-To: <> (=?utf-8?B?ItCa0L7QvdGM?= =?utf-8?B?0LrQvtCyINCV0LLQs9C10L3QuNC5Iidz?= message of "Tue, 7 Feb 2012 23:59:24 +0200")
References:  <>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
>>>>> "=D0=9A=D0=BE=D0=BD=D1=8C=D0=BA=D0=BE=D0=B2" =3D=3D =D0=9A=D0=BE=D0=
=BD=D1=8C=D0=BA=D0=BE=D0=B2 =D0=95=D0=B2=D0=B3=D0=B5=D0=BD=D0=B8=D0=B9 <kes=> writes:

=D0=9A=D0=BE=D0=BD=D1=8C=D0=BA=D0=BE=D0=B2> # rm *
=D0=9A=D0=BE=D0=BD=D1=8C=D0=BA=D0=BE=D0=B2> /bin/rm: Argument list too long.

=D0=9A=D0=BE=D0=BD=D1=8C=D0=BA=D0=BE=D0=B2> in this directory about 25000 f=
=D0=9A=D0=BE=D0=BD=D1=8C=D0=BA=D0=BE=D0=B2> but actually there is only one =
argument to rm it is '*' sign.

=D0=9A=D0=BE=D0=BD=D1=8C=D0=BA=D0=BE=D0=B2> Why rm get list of all files in=
 directore instead of deleting
=D0=9A=D0=BE=D0=BD=D1=8C=D0=BA=D0=BE=D0=B2> one by one?

It's the way Unix works.  Individual commands typically know nothing of
'*' or '[abc]'.  The shell "globs" the command, expanding it to all the
matching files, and then hands that list to the command as individual

However, sometimes that expansion exceeds the maximum argument size, as
you discovered.

If you have perl, try this:

  perl -e 'unlink glob("*")'

It uses Perl's internal glob() function, which can handle an unlimited
number of files.

Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<> <URL:>;
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See for Smalltalk discussion

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