Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!mips!dimacs.rutgers.edu!rutgers!mcdhup!inferno!shane From: shane@inferno.peri.com (Shane Bouslough) Newsgroups: comp.unix.questions Subject: Re: Number of files in a directory? Message-ID: <1991May29.175630.6450@inferno.peri.com> Date: 29 May 91 17:56:30 GMT References: <1146@mwtech.UUCP> Organization: Periphonics Corp. Lines: 27 From article <1146@mwtech.UUCP>, by martin@mwtech.UUCP (Martin Weitzel): > In article <1991May19.111727.18637@virtech.uucp> cpcahil@virtech.uucp (Conor P. Cahill) writes: > :mikeh@fsd.cpsc.ucalgary.ca (Michael Hoffos) writes: > :>[...] > :>how can you get the number of > :>files that are in a directory? > [...] > :If on a v7 style filesystem you can get the size of the directory and > :divide it by 16, but that only works on a single directory, is non-portable > :and definately doesn't work for BSD style file systems. > > And it will not work if you have deleted some files from the directory, > as directories don't shrink once they have been big (except you have a > special utility to compress them). However, if you're going to get the size of a directory, you'll probably open it anyway, so why not just read each entry and count those not deleted? > -- > Martin Weitzel, email: martin@mwtech.UUCP, voice: 49-(0)6151-6 56 83 -- Shane Bouslough | ...!rutgers!mcdhup!inferno!shane 516-467-0500 Periphonics Corp. | Ride Bike! 4000 Veterans Hwy. | "We're talking Mega-Ecstasy-Bliss!!!" Bohemia, NY 11716 | -David Lister, Red Dwarf