Date: Sat, 03 Nov 2007 15:24:23 +0100 From: Daniel Larsson <Daniel.Larsson@servicefactory.com> To: Daniel Bye <freebsd-questions@slightlystrange.org> Cc: FreeBSD Users Questions <freebsd-questions@freebsd.org> Subject: Re: Determining the number of files in a directory Message-ID: <1194099863.25962.1.camel@djllaptop.homeunix.net> In-Reply-To: <20071103124932.GB3207@torus.slightlystrange.org> References: <538619.51984.qm@web34408.mail.mud.yahoo.com> <20071103124151.GA3207@torus.slightlystrange.org> <20071103124932.GB3207@torus.slightlystrange.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--=-EGMdkG0eJloazHy4xEN+ Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Sat, 2007-11-03 at 12:49 +0000, Daniel Bye wrote: > On Sat, Nov 03, 2007 at 12:41:51PM +0000, Daniel Bye wrote: > > On Sat, Nov 03, 2007 at 05:27:06AM -0700, White Hat wrote: > > > This is probably a dumb question; however, I never let a little thing= like=20 > > > that bother me in the past. > >=20 > > Heheh! You and many more, my friend, myself absolutely included! > >=20 > > > Using FreeBSD-6.2 and Bash, how do I determine the number of files in= a=20 > > > given directory? I have tried all sorts of combinations using differe= nt=20 > > > flags with the 'ls' command; however, none of them displays the numbe= r of=20 > > > files in the directory. > >=20 > > $ ls | wc -l > >=20 > > will show you how many files and directories in the current (target) > > directory. To count just files, and exclude directories, you could try > > something like > >=20 > > $ find /target/directory -type f -print | wc -l >=20 > Except of course, that would descend into the subdirectories you're tryin= g > not to count... Sorry - an object lesson in not hitting send before you'v= e > tested what you scribbled. $ find /target/directory -maxdepth 1 -type f -print | wc -l should do what you want though. >=20 > Dan >=20 --=-EGMdkG0eJloazHy4xEN+ Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQBHLISX8CJVUq/zOt8RAqmVAKCFV23GyLq+FOpv6TxuaFSQUsdccACdFpQQ VfOwENPqNN0my+RO/u5oihE= =jo0/ -----END PGP SIGNATURE----- --=-EGMdkG0eJloazHy4xEN+--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1194099863.25962.1.camel>