0

I am using a find command this way:

find ./my_path -name "*.ext1" -exec echo {} \;

And it would work.

Now with multiple extensions, the following command would display several files :

find ./my_path -name "*.ext1" -o -name "*.ext2" 

But when using -exec:

find ./my_path -name "*.ext1" -o -name "*.ext2" -exec echo {} \;

No files are displayed. What am I doing wrong, shouldn't it display just the same files as my second example?

marked as duplicate by Stephen Kitt, Anthony Geoghegan, Stéphane Chazelas bash Sep 28 '16 at 13:24

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

You need to group the filters:

find ./my_path \( -name "*.ext1" -o -name "*.ext2" \) -exec echo {} \;

Not the answer you're looking for? Browse other questions tagged or ask your own question.