Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Mar 2004 08:37:26 +0100
From:      Uwe Doering <gemini@geminix.org>
To:        questions@freebsd.org
Subject:   Re: Simple file count question
Message-ID:  <4056AEB6.4030809@geminix.org>
In-Reply-To: <000701c40b26$3d5797f0$0200000a@redline>
References:  <002501c40b24$8c600e10$0301a8c0@daveslaptop> <000701c40b26$3d5797f0$0200000a@redline>

next in thread | previous in thread | raw e-mail | index | archive | help
Craig Reyenga wrote:
> find /path/to/dir -type f -name db\* -print | wc -l
> 
> would count the number of files that begin with 'db' in the name, under the
> '/path/to/dir' directory. man find and man wc for more action.

Be careful in case that directory contains subdirectories, since 'find' 
will traverse them by default as well.  If you want to count files only 
in the directory level of '/path/to/dir' you may want to add '-maxdepth 
1', like so:

find /path/to/dir -type f -name db\* -maxdepth 1 -print | wc -l

    Uwe
-- 
Uwe Doering         |  EscapeBox - Managed On-Demand UNIX Servers
gemini@geminix.org  |  http://www.escapebox.net



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4056AEB6.4030809>