From owner-freebsd-questions@FreeBSD.ORG Tue Jul 6 14:26:08 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 183DF16A4CE for ; Tue, 6 Jul 2004 14:26:08 +0000 (GMT) Received: from rwcrmhc13.comcast.net (rwcrmhc13.comcast.net [204.127.198.39]) by mx1.FreeBSD.org (Postfix) with ESMTP id EDA3543D1F for ; Tue, 6 Jul 2004 14:26:07 +0000 (GMT) (envelope-from freebsd-questions-local@be-well.ilk.org) Received: from be-well.no-ip.com ([66.30.196.44]) by comcast.net (rwcrmhc13) with ESMTP id <20040706142607015003hib5e>; Tue, 6 Jul 2004 14:26:07 +0000 Received: by be-well.no-ip.com (Postfix, from userid 1147) id 756F774; Tue, 6 Jul 2004 10:26:06 -0400 (EDT) Sender: lowell@be-well.ilk.org To: "Steve Bertrand" References: <3703.209.167.16.15.1089123354.squirrel@209.167.16.15> From: Lowell Gilbert Date: 06 Jul 2004 10:26:06 -0400 In-Reply-To: <3703.209.167.16.15.1089123354.squirrel@209.167.16.15> Message-ID: <44pt79mcu9.fsf@be-well.ilk.org> Lines: 19 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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:26:08 -0000 "Steve Bertrand" writes: > 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). find /path-to-directory -type f -print | xargs rm 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.