From owner-freebsd-questions@FreeBSD.ORG Tue Jul 6 14:39:45 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1FA4816A4CE for ; Tue, 6 Jul 2004 14:39:45 +0000 (GMT) Received: from mbox.ibctech.ca (dev.eagle.ca [209.167.58.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7089043D53 for ; Tue, 6 Jul 2004 14:39:43 +0000 (GMT) (envelope-from iaccounts@ibctech.ca) Received: (qmail 16379 invoked by uid 1002); 6 Jul 2004 14:39:53 -0000 Received: from iaccounts@ibctech.ca by pearl.ibctech.ca by uid 89 with qmail-scanner-1.22 (clamscan: 0.73. spamassassin: 2.63. Clear:RC:1(127.0.0.1):. Processed in 1.047504 secs); 06 Jul 2004 14:39:53 -0000 Received: from unknown (HELO pearl.ibctech.ca) (127.0.0.1) by localhost.ibctech.ca with SMTP; 6 Jul 2004 14:39:52 -0000 Received: from 209.167.16.15 (SquirrelMail authenticated user steve@ibctech.ca); by pearl.ibctech.ca with HTTP; Tue, 6 Jul 2004 10:39:52 -0400 (EDT) Message-ID: <3849.209.167.16.15.1089124792.squirrel@209.167.16.15> In-Reply-To: <44pt79mcu9.fsf@be-well.ilk.org> References: <3703.209.167.16.15.1089123354.squirrel@209.167.16.15> <44pt79mcu9.fsf@be-well.ilk.org> Date: Tue, 6 Jul 2004 10:39:52 -0400 (EDT) From: "Steve Bertrand" To: "Lowell Gilbert" User-Agent: SquirrelMail/1.4.3a X-Mailer: SquirrelMail/1.4.3a MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal cc: freebsd-questions@freebsd.org Subject: Re: Removing thousands of files using rm X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Jul 2004 14:39:45 -0000 >> I often have the need to remove hundreds or even thousands of files from >> a >> single directory (very often). Using rm, I usually get: >> >> pearl# rm -rvf * >> /bin/rm: Argument list too long. >> >> Is there any way to work around this instead of having to select a small >> bunch of files at a time to remove? > > Not exactly, but find(1) will do the job for you. > Typically you would use it with xargs(1). Thanks to all who replied. This following suggestion worked very, very well, and extremely quickly: > find /path-to-directory -type f -print | xargs rm I'll read up on find and xargs as this approach appears to be easily scripted and cronned. Tks again! STeve > > You may need to add some options to those commands depending on your > situation. For example, if you have embedded whitespace characters in > the file names or if you don't want to descend into subdirectories. >