3

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?

countermode
  • 7,533
  • 5
  • 31
  • 58
aze
  • 185

1 Answers1

5

You need to group the filters:

find ./my_path \( -name "*.ext1" -o -name "*.ext2" \) -exec echo {} \;
jlliagre
  • 61,204