How to run batch job for multiple extensions with find command?

123 Views Asked by At

I am trying to use jpegoptim for optimizing all jpg and jpeg images on my server recursively.

This command is working:

find . -type f -name "*.jpg"   -exec jpegoptim --strip-all {} \;

but i need something like this:

find . -type f -name "*.jpg" -or -name "*.jpeg"   -exec jpegoptim --strip-all {} \;

which is not working. Is there a way to do that ?

1

There are 1 best solutions below

2
On BEST ANSWER

Try something like this:

find . -type f \( -name "*.jpg" -o -name "*.jpeg" \) -exec jpegoptim --strip-all {} \;