Using find command with variables

I have a number of files in the /tmp directory with PET-DOG in their name. I want to delete them, leaving only files with PET-CAT and PET-HORSE. I'd like to use the find command to locate those files (by using a variable) and then I'd like to delete them. However, I can't find a way to do this. I found that -iname with a variable might work, but it didn't.

Here is what I have:

find . -name \*${VARY}\* -print

Doesn't work. Tried

 find . -iname \*${VARX}\* -print 

Where VARY= PET-DOG.
But I do not have -iname as an option.

I realize I could also search for the PET-DOG string, but I'd like to use find with the variable to do it. Does anyone know how? I assume that after you found the files, you could use xargs rm -f to delete them.

What is the output of:

uname -a
echo $SHELL

Hello newbie2010,

Following may help you in same, I tested in bash .
1st please check the file names which you want to delete, if satisfied with result use 2nd command.

VAR="PET-DOG"
find -type f -name "*$VAR*"
./TEST-PET-DOG-234
./TEST-PET-DOG-TEST

I got above results as I have created some test files to check it.

2nd command:

find -type f -name "*$VAR*" -exec rm -rf {} \;

Thanks,
R. Singh

Trying to infer your problem from post #1, I guess it's a case problem, as -iname is needed but does not work. Try assigning VARY with the upper case partial file name and then

find . | awk -vNM="$VARY" 'toupper($0) ~ NM {print "ls \""$0"\""}' | sh

and replace the ls with rm when happy.