[ale] Bash scripting question #2

Dow_Hurst dhurst at mindspring.com
Fri Feb 18 09:27:54 EST 2005


Thanks for the answers, guys!  I wasn't aware of the -o option.  I'll try it out later today.
Dow


-----Original Message-----
From: Geoffrey <esoteric at 3times25.net>
Sent: Feb 18, 2005 7:26 AM
To: Atlanta Linux Enthusiasts <ale at ale.org>
Subject: Re: [ale] Bash scripting question #2

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
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale


No sig.



More information about the Ale mailing list