[ale] Bash scripting question #2
Geoffrey
esoteric at 3times25.net
Fri Feb 18 07:34:50 EST 2005
Michael Hirsch wrote:
> On Thu, 17 Feb 2005 22:51:51 -0500, Dow Hurst <Dow.Hurst at mindspring.com> wrote:
>
>>So the || in the do loop says to only execute the echo if the test of
>>the link being a file that exists returns true?
>
>
> No, exactly the opposite. It is a logical "OR", so it only executes
> if the test returns false. If $fn is not a regular file "test -f $fn"
> is false, so the other half of the OR needs to be tested.
>
> I've never seen || used the way you use it in your while loop. I
> don't think it works like that. You have
> if [ -f $file1 || file2 ] ...
> which means "if file1 is a file or file2". Note that I didn't write
> "if file1 is a file or file2 is a file". I don't know what it means
> to test just a filename. I think you need multiple -f flags like:
> if [ -f $file1 || -f $file2 ] ...
That won't work, that's why I used the '-o' syntax in an earlier post.
You can do it this way:
if [ -f foo ] || [ -f bar ]....
But that's more typing.. :)
--
Until later, Geoffrey
More information about the Ale
mailing list