Bash Script Ques
Brad De Vries
devriesbj
Mon May 17 11:48:13 PDT 2004
--- Michael Hipp <Michael at hipp.com> 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?
>
> Thanks,
> Michael
Here's one more suggestion to go with the several
you've already received.
#!/bin/sh
FILES=`ls myfile* 2>/dev/null`
if [ ! -z "$FILES" ]; then
echo "File(s) found"
else
echo "No files found"
fi
HTH,
Brad.
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
More information about the Linux-users
mailing list