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.