Date: Tue, 07 Feb 2012 14:06:12 -0800 From: merlyn@stonehenge.com (Randal L. Schwartz) To: =?utf-8?B?0JrQvtC90YzQutC+0LIg0JXQstCz0LXQvdC40Lk=?= <kes-kes@yandex.ru> Cc: freebsd-questions@freebsd.org Subject: Re: 'rm' Can not delete files Message-ID: <86haz2uwmj.fsf@red.stonehenge.com> In-Reply-To: <1237723287.20120207235924@yandex.ru> (=?utf-8?B?ItCa0L7QvdGM?= =?utf-8?B?0LrQvtCyINCV0LLQs9C10L3QuNC5Iidz?= message of "Tue, 7 Feb 2012 23:59:24 %2B0200") References: <1237723287.20120207235924@yandex.ru>
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= -kes@yandex.ru> 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= iles, =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 arguments. 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. --=20 Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.posterous.com/ for Smalltalk discussion
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86haz2uwmj.fsf>