From owner-freebsd-questions Thu Oct 23 19:59:06 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id TAA15831 for questions-outgoing; Thu, 23 Oct 1997 19:59:06 -0700 (PDT) (envelope-from owner-freebsd-questions) Received: from mo.cc.swin.edu.au (mo.cc.swin.edu.au [136.186.1.27]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id TAA15801 for ; Thu, 23 Oct 1997 19:58:23 -0700 (PDT) (envelope-from netserv@mo.cc.swin.edu.au) Received: by mo.cc.swin.edu.au (8.8.5/8.8.0) id CAA03111; Fri, 24 Oct 1997 02:58:11 GMT From: netserv@mo.cc.swin.edu.au (Bob Schorer) Message-Id: <199710240258.CAA03111@mo.cc.swin.edu.au> Subject: Re: deleted huge directory To: questions@FreeBSD.org Date: Fri, 24 Oct 1997 12:58:10 +1000 (EST) X-Mailer: ELM [version 2.4 PL21] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk The 'ls' command fails because it needs to sort the entries and must therefore read them into memory first. 'find' should work ok, or you can use the following small program (if you want, you could add a call to the unlink function to remove each file within the loop). Bob Schorer #include #include #include #ifdef DIRENT #include #define direct dirent #else #include #endif main(argc, argv) int argc; char **argv; { DIR *fd; struct direct *cat; if (!(fd=opendir(*(argv+1)))) { printf("Directory not found\n"); exit(0); } while ((cat=(struct direct*)readdir(fd))) printf("%s\n", cat->d_name); closedir(fd); }