From owner-freebsd-questions@FreeBSD.ORG Tue Feb 7 22:06:20 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CED341065672 for ; Tue, 7 Feb 2012 22:06:20 +0000 (UTC) (envelope-from merlyn@stonehenge.com) Received: from mail.mroute.net (lax-gw09.mailroute.net [199.89.0.109]) by mx1.freebsd.org (Postfix) with ESMTP id B3B2E8FC14 for ; Tue, 7 Feb 2012 22:06:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by lax-gw09.mroute.net (Postfix) with ESMTP id 3AC7A17018C; Tue, 7 Feb 2012 22:06:20 +0000 (GMT) X-Virus-Scanned: by MailRoute Received: from red.stonehenge.com (red.stonehenge.com [208.79.95.2]) by lax-gw09.mroute.net (Postfix) with ESMTP id B6344170194; Tue, 7 Feb 2012 22:06:13 +0000 (GMT) Received: by red.stonehenge.com (Postfix, from userid 1001) id 2641E2D69; Tue, 7 Feb 2012 14:06:13 -0800 (PST) From: merlyn@stonehenge.com (Randal L. Schwartz) To: =?utf-8?B?0JrQvtC90YzQutC+0LIg0JXQstCz0LXQvdC40Lk=?= References: <1237723287.20120207235924@yandex.ru> x-mayan-date: Long count = 12.19.19.2.2; tzolkin = 11 Ik; haab = 10 Pax Date: Tue, 07 Feb 2012 14:06:12 -0800 In-Reply-To: <1237723287.20120207235924@yandex.ru> (=?utf-8?B?ItCa0L7QvdGM?= =?utf-8?B?0LrQvtCyINCV0LLQs9C10L3QuNC5Iidz?= message of "Tue, 7 Feb 2012 23:59:24 +0200") Message-ID: <86haz2uwmj.fsf@red.stonehenge.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-questions@freebsd.org Subject: Re: 'rm' Can not delete files X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Feb 2012 22:06:20 -0000 >>>>> "=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 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 Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.posterous.com/ for Smalltalk discussion