From owner-freebsd-questions@FreeBSD.ORG Sat Nov 3 15:32:29 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5CAB516A46B for ; Sat, 3 Nov 2007 15:32:29 +0000 (UTC) (envelope-from Daniel.Larsson@servicefactory.com) Received: from ark.servicefactory.se (ark.servicefactory.se [217.13.255.29]) by mx1.freebsd.org (Postfix) with ESMTP id DD09913C491 for ; Sat, 3 Nov 2007 15:32:28 +0000 (UTC) (envelope-from Daniel.Larsson@servicefactory.com) Received: from [127.0.0.1] (localhost.servicefactory.se [127.0.0.1]) by ark.servicefactory.se (8.12.11/8.12.10) with ESMTP id lA3EONfO010306; Sat, 3 Nov 2007 15:24:23 +0100 (CET) (envelope-from Daniel.Larsson@servicefactory.com) From: Daniel Larsson To: Daniel Bye 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> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-EGMdkG0eJloazHy4xEN+" Date: Sat, 03 Nov 2007 15:24:23 +0100 Message-Id: <1194099863.25962.1.camel@djllaptop.homeunix.net> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Cc: FreeBSD Users Questions Subject: Re: Determining the number of files in a directory X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Nov 2007 15:32:29 -0000 --=-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+--