Bash Script Ques
David Aikema
david
Mon May 17 11:48:11 PDT 2004
On Sunday, June 8, 2003, at 02:28 PM, Michael Hipp wrote:
> Hello, first post (in a long time) ...
>
> I thought to do something like:
>
> if [ -f myfile* ]; then
> # do something
> fi
>
> That's to find if there are one or more like myfile001, myfile002, but
> it reports an error "too many arguments" if there is more than one.
> Any simple/elegant way to do this?
Well, with a wildcard at the end there it seems unlikely that such an
expression could ever return true in any case.
You're probably stuck with
if [ -f myfile001 ] || [ -f myfile002 ] ...; then
# do something
fi
Maybe one of those on the list who are more experienced with Bash
scripting can offer you a better solution.
David Aikema
More information about the Linux-users
mailing list