From owner-freebsd-questions@FreeBSD.ORG Tue Jul 6 15:13:38 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 BB63916A4CE for ; Tue, 6 Jul 2004 15:13:38 +0000 (GMT) Received: from clunix.cl.msu.edu (clunix.cl.msu.edu [35.9.2.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 48AEE43D39 for ; Tue, 6 Jul 2004 15:13:38 +0000 (GMT) (envelope-from jerrymc@clunix.cl.msu.edu) Received: (from jerrymc@localhost) by clunix.cl.msu.edu (8.11.7p1+Sun/8.11.7) id i66FDLa16321; Tue, 6 Jul 2004 11:13:21 -0400 (EDT) From: Jerry McAllister Message-Id: <200407061513.i66FDLa16321@clunix.cl.msu.edu> To: iaccounts@ibctech.ca (Steve Bertrand) Date: Tue, 6 Jul 2004 11:13:19 -0400 (EDT) In-Reply-To: <3849.209.167.16.15.1089124792.squirrel@209.167.16.15> from "Steve Bertrand" at Jul 06, 2004 10:39:52 AM X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 15:13:38 -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 > The find method is right for doing this now and then. But if you are doing this frequently and there is a reasonable pattern to the file names you are crating and then deleting, you might want to create a special directory for them and then when it is time to delete them, just do an rm -rf on the directory - as in: mkdir junkdir fill it up with those files and do whatever you need. rm -rf junkdir t might take some thought to categorize the files so the right ones are stashed in the directory. ////jerry > 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. > > > > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" >