[ale] Bash scripting question #2

Michael Hirsch mdhirsch at gmail.com
Fri Feb 18 00:02:53 EST 2005


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 ] ...

Michael



More information about the Ale mailing list