From owner-freebsd-questions Mon May 28 13:59:58 2001 Delivered-To: freebsd-questions@freebsd.org Received: from phoenix.volant.org (dickson.phoenix.volant.org [205.179.79.193]) by hub.freebsd.org (Postfix) with ESMTP id 9991F37B423 for ; Mon, 28 May 2001 13:59:53 -0700 (PDT) (envelope-from patl@Phoenix.Volant.ORG) Received: from asimov.phoenix.volant.org ([205.179.79.65]) by phoenix.volant.org with esmtp (Exim 1.92 #8) id 154U7E-0002mx-00; Mon, 28 May 2001 13:59:52 -0700 Received: from localhost (localhost [127.0.0.1]) by asimov.phoenix.volant.org (8.9.3+Sun/8.9.3) with SMTP id NAA06907; Mon, 28 May 2001 13:59:49 -0700 (PDT) From: patl@Phoenix.Volant.ORG Date: Mon, 28 May 2001 13:59:49 -0700 (PDT) Reply-To: patl@Phoenix.Volant.ORG Subject: Re: Need help with Bash function To: Mike Meyer Cc: Jim Conner , Duke Normandin <01031149@3web.net>, questions@freebsd.org In-Reply-To: <15122.32514.853271.557888@guru.mired.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 28-May-01 at 09:39, Mike Meyer (mwm@mired.org) wrote: > Jim Conner types: > > The only thing you are lacking is quotes in your condition... > > > > function ezq() { > > if [ -a "~/tmp/*" ] > > then > > echo -e "there's something here....\n" > > else > > echo -e "empty....\n" > > fi > > } > > > > Now, I ususally use ksh but bash should be able to do the same thing. > > That doesn't work in bash here. I suspect that the version of test > built into ksh and bash are different. Just out of curiosity, did you > test it with more than one file in ~/tmp? I missed the beginning of the thread; so I'm not sure what the actual goal is; but you should be able to use: if [ $(ls -a /tmp | wc -l) -eq 2 ] then echo "empty...\n" else echo "there's something here...\n" fi Note that this form also detects hidden files (those starting with a period.) To ignore them, change the test to: if [ $(ls /tmp | wc -l) -eq 0 ] If you want to be absolutely certain that you're using the built-in version of test, use if builtin [ $(ls ... -Pat To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message