From owner-freebsd-questions@FreeBSD.ORG Mon Mar 15 23:37:30 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0276216A4CE for ; Mon, 15 Mar 2004 23:37:30 -0800 (PST) Received: from geminix.org (gen129.n001.c02.escapebox.net [213.73.91.129]) by mx1.FreeBSD.org (Postfix) with ESMTP id 727CF43D41 for ; Mon, 15 Mar 2004 23:37:29 -0800 (PST) (envelope-from gemini@geminix.org) Message-ID: <4056AEB6.4030809@geminix.org> Date: Tue, 16 Mar 2004 08:37:26 +0100 From: Uwe Doering Organization: Private UNIX Site User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.6) Gecko/20040119 X-Accept-Language: en-us, en MIME-Version: 1.0 To: questions@freebsd.org References: <002501c40b24$8c600e10$0301a8c0@daveslaptop> <000701c40b26$3d5797f0$0200000a@redline> In-Reply-To: <000701c40b26$3d5797f0$0200000a@redline> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Received: from gemini by geminix.org with asmtp (TLSv1:AES256-SHA:256) (Exim 3.36 #1) id 1B398i-0006nf-00; Tue, 16 Mar 2004 08:37:28 +0100 Subject: Re: Simple file count question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Mar 2004 07:37:30 -0000 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