Linux command line find escape question mark

findlinux

For some reason I would like to delete all files names like "*.jpg?" (the filename is ending with a real ?)

I tried this

find /var/www/ -type f -name "*.jpg\?"

and

find /var/www/ -type f -name "*.jpg?"

but this doesn't work
how can i do that ?

Best Answer

Interestingly both of your commands work on the CentOS 6.5 find 4.4.2 system I have to hand. You can try using single quotes '

find /var/www/ -type f -name '*.jpg?'

If this works and it's available in your find, you can use the -delete argument to find to delete the files. This does away with the need for xargs and print0 and the like. Be sure to be ensure the find command works correctly before adding the the delete though.