Re: Simple Scripting ? (Is directory empty?)


Subject: Re: Simple Scripting ? (Is directory empty?)
From: Adam Price (Adam@oldchildrensbooks.com)
Date: Fri Dec 17 1999 - 19:56:24 MST


On Fri, 17 Dec 1999, Tom Pollard wrote:
>
> Try this, then:
>
> if [ -z "`ls /var/qmail/alias/pppdir/new/`" ]; then
> echo 'Its empty'
> else
> echo 'Its not empty'
> fi
>
> (I'm a big fan of the -z and -n operators.) Also, in a conditional
> statement (like 'if') always double-quote anything that gets expanded,
> like a variable or a back-tick command. If you don't double-quote it and
> it returns the empty string, it'll be as though there was never anything
> there in the first place, which is not usually what you want. This is
> different from how csh conditionals work, so it's a mistake many people
> make.
>
> Tom
>

Except that you gave me the wrong flag (I want to send mail if there IS
something in the directory, not if it is empty) this works GREAT! Thanks
a bundle.

        -Adam

--

Time capsules sure are different from time bombs. -Peter Stampfel



This archive was generated by hypermail 2a24 : Sun Jan 02 2000 - 12:12:58 MST