From owner-freebsd-questions@FreeBSD.ORG Sat Nov 3 14:41:20 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 A702716A420 for ; Sat, 3 Nov 2007 14:41:20 +0000 (UTC) (envelope-from LoN_Kamikaze@gmx.de) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by mx1.freebsd.org (Postfix) with SMTP id EF99B13C48E for ; Sat, 3 Nov 2007 14:41:19 +0000 (UTC) (envelope-from LoN_Kamikaze@gmx.de) Received: (qmail invoked by alias); 03 Nov 2007 14:14:21 -0000 Received: from nat-wh-1.rz.uni-karlsruhe.de (EHLO mobileKamikaze.norad) [129.13.72.169] by mail.gmx.net (mp044) with SMTP; 03 Nov 2007 15:14:21 +0100 X-Authenticated: #5465401 X-Provags-ID: V01U2FsdGVkX1/qQABdAAnqwHJqHr/uucErfiSVMSY6oBPFEYTPqD CA7btkMKxfVPpn Message-ID: <472C823B.8020901@gmx.de> Date: Sat, 03 Nov 2007 15:14:19 +0100 From: "[LoN]Kamikaze" User-Agent: Thunderbird 2.0.0.6 (X11/20071101) MIME-Version: 1.0 To: FreeBSD Users Questions References: <538619.51984.qm@web34408.mail.mud.yahoo.com> <20071103124151.GA3207@torus.slightlystrange.org> <20071103124932.GB3207@torus.slightlystrange.org> In-Reply-To: <20071103124932.GB3207@torus.slightlystrange.org> X-Enigmail-Version: 0.95.5 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 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 14:41:20 -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. > > Dan > Well just use the Unix tool for everything - grep: $ ls -F | grep -Ev '/$'|wc -l or if you also want to exclude symlinks: $ ls -F | grep -Ev '/$|@$'|wc -l