From owner-freebsd-questions Thu Aug 10 12:15:55 2000 Delivered-To: freebsd-questions@freebsd.org Received: from q.closedsrc.org (ip233.gte15.rb1.bel.nwlink.com [209.20.244.233]) by hub.freebsd.org (Postfix) with ESMTP id 45A4137BB4A for ; Thu, 10 Aug 2000 12:15:14 -0700 (PDT) (envelope-from lplist@closedsrc.org) Received: from localhost (lplist@localhost) by q.closedsrc.org (8.11.0/8.11.0) with ESMTP id e7AJDtH30016; Thu, 10 Aug 2000 12:13:55 -0700 (PDT) (envelope-from lplist@closedsrc.org) Date: Thu, 10 Aug 2000 12:13:55 -0700 (PDT) From: Linh Pham To: Emmanuel Gravel Cc: freebsd-questions@FreeBSD.ORG Subject: Re: [OT] shell scripting, testing for files In-Reply-To: <20000810191204.27627.qmail@web1607.mail.yahoo.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, 10 Aug 2000, Emmanuel Gravel mumbled: > First off, I'm not subscribed through this email > address, but I will follow the online archives, so > if you simply "reply" it'll take longer for me to > answer :) > > OK, here's my question. I'm trying to create a simple > shell script which will test for the existance of a > file whose name follows a pattern (ex: r*.txt). If > I use "if test -e r*.txt" it works very well as long > as I don't have more than one file with that pattern > (in which case it chokes). If I use "if return=`ls > r*.txt`" it works well if I have one or more files > (in which case it saves the output to $return), > however > if there are now files which follow the pattern, I > get an unwanted error message from ls (that I would > want to suppress, but haven't found any option to do > so). So neither method works for my purpose, and I > don't know where to look. Anywone have an idea on how > I can check for the existance of one or more files of > a certain name pattern? Essentially, that's all I want > to know (if there is, I can always do an ls later on). Have you tried: find /PATH_TO_START_SEARCH_AT | grep PATTERN ? // Linh Pham // http://closedsrc.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message