[ale] bash scripting question

Geoffrey esoteric at 3times25.net
Wed Sep 10 19:55:36 EDT 2003


Kevin Krumwiede wrote:
> I need a boolean statement that will evaluate to true if one or more
> files matching a wildcard exist.  I tried [ -f ... ], it works if
> there is exactly one matching file, but not if there are more.

You can't use wild card char. in the  [ -f .. ], your best bet is a case 
statement.

You could do it with a for loop:

for fn in fn1 fn2.....fnN; do

if [ -f $fn ]; then
	# do what you want to for the match here then break the loop
	break;
fi
done

-- 
Until later: Geoffrey		esoteric at 3times25.net

The latest, most widespread virus?  Microsoft end user agreement.
Think about it...



More information about the Ale mailing list