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 > > > that bother me in the past. > > > > Heheh! You and many more, my friend, myself absolutely included! > > > > > Using FreeBSD-6.2 and Bash, how do I determine the number of files in a > > > given directory? I have tried all sorts of combinations using different > > > flags with the 'ls' command; however, none of them displays the number of > > > files in the directory. > > > > $ ls | wc -l > > > > 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 > > > > $ find /target/directory -type f -print | wc -l > > Except of course, that would descend into the subdirectories you're trying > not to count... Sorry - an object lesson in not hitting send before you've > tested what you scribbled.
$ find /target/directory -maxdepth 1 -type f -print | wc -l should do what you want though. > > Dan >
signature.asc
Description: This is a digitally signed message part