From owner-freebsd-questions Thu Aug 10 13:54:39 2000 Delivered-To: freebsd-questions@freebsd.org Received: from mta02-svc.ntlworld.com (mta02-svc.ntlworld.com [62.253.162.42]) by hub.freebsd.org (Postfix) with ESMTP id DEEFB37BC7B for ; Thu, 10 Aug 2000 13:54:34 -0700 (PDT) (envelope-from mark@ukug.uk.freebsd.org) Received: from parish.my.domain ([62.255.96.131]) by mta02-svc.ntlworld.com (InterMail vM.4.01.02.27 201-229-119-110) with ESMTP id <20000810215338.OZGT3760.mta02-svc.ntlworld.com@parish.my.domain>; Thu, 10 Aug 2000 21:53:38 +0000 Received: (from mark@localhost) by parish.my.domain (8.9.3/8.9.3) id VAA00900; Thu, 10 Aug 2000 21:54:23 +0100 (BST) (envelope-from mark) Date: Thu, 10 Aug 2000 21:54:23 +0100 From: Mark Ovens To: Emmanuel Gravel Cc: freebsd-questions@freebsd.org Subject: Re: [OT] shell scripting, testing for files Message-ID: <20000810215423.B254@parish> References: <20000810191204.27627.qmail@web1607.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.2.5i In-Reply-To: <20000810191204.27627.qmail@web1607.mail.yahoo.com>; from e_gravel@yahoo.com on Thu, Aug 10, 2000 at 12:12:04PM -0700 Organization: Total lack of Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, Aug 10, 2000 at 12:12:04PM -0700, Emmanuel Gravel wrote: > 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). To suppress the error from ls(1) try `ls 2>/dev/null`: $ ls fdjk ls: fdjk: No such file or directory $ ls fdjk 2>/dev/null $ > 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). > > Thanks! > > Emmanuel > > __________________________________________________ > Do You Yahoo!? > Kick off your party with Yahoo! Invites. > http://invites.yahoo.com/ > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message -- 4.4 - The number of the Beastie ________________________________________________________________ 51.44°N FreeBSD - The Power To Serve http://www.freebsd.org 2.057°W My Webpage http://ukug.uk.freebsd.org/~mark mailto:marko@freebsd.org http://www.radan.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message