check if file exists with pattern matching

Hello friends,

I am writing a simple shell script which will copy one particular type of files to backup folder if files exists. If files doesn't exists, mv command should not be executed.
My file pattern is like wcm-spider-maestro.log.2009-07-15, wcm-spider-maestro.log.2009-07-16 etc..
I have written this way

find . -maxdepth 1 -name "wcm-spider-maestro.log."
code=$?
if [$code -eq "0"]
then
mv wcm-spider-maestro.log.
/backup
fi

above code working fine if files exists on current directory, if files doesn't exists, it showing message like "mv: cannot stat `wcm-spider-maestro.log.*': No such file or directory", I don't want to show that message. I tried with "ls" command also, it is also throwing some message if files not exists.
Please suggest me how to move files without error messages.

Thanks.

That happens becouse find returns 0 even if no files have been found:

$ mkdir newdir
$ find ./newdir/ -name "file"
$ echo $?
0

You should user xargs or -exec option of find:

find . -maxdepth 1 -name "wcm-spider-maestro.log.*" -exec mv {} /bakcup \;

and better

find . -maxdepth 1 -name "wcm-spider-maestro.log.*" | xargs mv {} /backup

Still I am getting below error
mv: cannot stat `{}': No such file or directory

Which statement gives you error?

find . -maxdepth 1 -name "wcm-spider-maestro.log.*" | xargs mv {} backup/

above statement giving message if files not exists on current directory.

It should be like

find . -maxdepth 1 -name "wcm-spider-maestro.log.*" | xargs -i mv {} backup/

Yes, it's working. Thank you.