*Quickly* counting the number of files on a partition

E K ekg_ab-FFYn/CNdgSA at public.gmane.org
Thu Jan 19 16:01:20 UTC 2006


You can also use 'find' (to list the files) in
combination with "wc" (to count the list). That will
work with directory entry rather than inode (which is
not available on smb file systems anyways).

EK

--- Madison Kelly <linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org> wrote:

> Ian Zimmerman wrote:
> > Madison>    Can I *quickly* get the number of
> files (and dirs, links,
> > Madison> etc) on a given partition or under a
> certain directory? The two
> > Madison> keeps are "quickly" and "partition"; it's
> can't traverse file
> > Madison> systems /or/ be limited to a directory
> (and it's sub
> > Madison> directories).
> > 
> > Depends:
> > 
> > 1/ what you mean by "file".  Most Unix filesystems
> can link multiple
> > names to a single entity known as inode.
> 
> Files, directories and symlinks. Hard links and
> special files/devices I 
> can ignore.
> 
> > 2/ if you need _just_ complete partitions or
> arbitrary directory trees.
> > 
> > If you're fine with counting just inodes on a
> complete partition, the
> > answer is yes: man statfs(2) or man stat(1) (in
> particular the -f flag).
> > 
> > Otherwise, you need someone smarter than me to
> answer :)
> 
> w00ts!!
> 
>    '# stat -f /' (where '/' is the root partition)
> works absolutely 
> beautifully on 'ext*' file systems (at least).
> However, it doesn't work 
> on an SMB mounted partitions (and others?) though...
> 
>    This is a huge step forward, but if you or anyone
> can think of a 
> similar trick for other file systems (or perhaps a
> file system-agnostic 
> method) that would be really helpful, too.
> 
>    In the mean time, I can check the FS and if it's
> one that this trick 
> will work on I can go ahead and use the nicer
> progress bar and just fall 
> back on the current scheme for unsupported file
> systems... at least 
> until I can find similar tricks for them, too.
> 
> Thank you *very* much!!
> 
> Madison
> 
> -- 
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>            Madison Kelly (Digimer)
>     TLE-BU; The Linux Experience, Back Up
> Main Project Page:  http://tle-bu.org
> Community Forum:    http://forum.tle-bu.org
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> --
> The Toronto Linux Users Group.      Meetings:
> http://tlug.ss.org
> TLUG requests: Linux topics, No HTML, wrap text
> below 80 columns
> How to UNSUBSCRIBE:
> http://tlug.ss.org/subscribe.shtml
> 



	

	
		
__________________________________________________________ 
Find your next car at http://autos.yahoo.ca
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list