[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Listing number of files

On Wed, Jun 09, 2004 at 06:59:53PM +0100, Dylan Parry wrote:
> To: "For users of Fedora Core releases" <fedora-list redhat com>
> Date: Wed, 09 Jun 2004 18:59:53 +0100
> From: "Dylan Parry" <me dylanparry com>
> Subject: Re: Listing number of files
> Reply-To: For users of Fedora Core releases <fedora-list redhat com>
> On Wed, 9 Jun 2004 13:52:08 -0400, Matt Brodeur  
> <mbrodeur+rhlp NextTime com> wrote:
> >>...for example, I could find out exactly how many OGG files I have in  
> >>total :)
> >
> >   Something like:
> >$ find . -type f -iname \*.ogg  | wc -l
> Thanks, this does the job nicely. Jeremiah: your solution, although giving  
> me a figure, seems to me a little out so I'm not exactly sure what else it  
> is counting... :)

It is counting dirs and other stuff including, informational
lines like "total xxx" and blank lines for formatting.  Dirs 
get counted twice.

 $ ll -R lib |wc -l
 $ find lib -type f | wc -l

Since ll is a default alias (ll='ls -l --color=tty') specific to bash
and these flavors of linux it is not good fuel for examples without a comment
that it is an alias.  i.e. man ll finds nothing of value.

Inspect the output and see what is cooking.  Recursive ls listings
are good stuff, just not exactly what is needed here.

 $ ll -R lib | less

It might be valuable to notice files that are not .ogg too.
Compare the results of this pair.

 $ find . -type f -iname \*.ogg  | wc -l
 $ find . -type f                | wc -l

Friends of regular expressions will wonder about the dot
and will be happy to see the  -iregex flag.

  $  mkdir gark
  $ touch gark/gllogg
  $ find . -type f -iname \*ogg  | wc -l
  $ find . -type f -iname \*.ogg  | wc -l

System admins will find that find is a fine friend.

	T o m  M i t c h e l l 
	/dev/null the ultimate in secure storage.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]