if statement to check files with different ending but same starting name

I am trying to check if files staring with filename but ending with diffent dates e.g. filename.2011-10-25.

The code I am using is below

if [ ! -f ~/filename.* ]

It works find only if one file is present but returns binary operator expected
when there are mulptiple files.

Please help me correcting it. I wanna use if statement only.

TIA

Not sure if this is what you're looking for but you can use a loop like:

for file in filename.*
do
  ....
done

Hi Franklin

Thanks for the reply ... But I need to use if statement as I have another if condition to && with it..

What shell are you using, and what are you actually trying to do?

It is quite normal since that test is for "file" and file is one... So what is to follow?

works fine for me,is that what you are trying

$ ls -1
a.1024
a.1025
c

$if [ ! -f ~/a.* ]
> then
> echo "success"
> else
> echo "fail"
> fi
fail

Since there are 2 files , it will give message as fail, Does this help ?