Date: Mon, 28 May 2001 13:59:49 -0700 (PDT) From: patl@Phoenix.Volant.ORG To: Mike Meyer <mwm@mired.org> Cc: Jim Conner <jconner@enterit.com>, Duke Normandin <01031149@3web.net>, questions@freebsd.org Subject: Re: Need help with Bash function Message-ID: <ML-3.4.991083589.5627.patl@asimov.phoenix.volant.org> In-Reply-To: <15122.32514.853271.557888@guru.mired.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 28-May-01 at 09:39, Mike Meyer (mwm@mired.org) wrote: > Jim Conner <jconner@enterit.com> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ML-3.4.991083589.5627.patl>