BhajjiMaga
BhajjiMaga

Reputation: 221

how to use find command for multiple file names?

I have to search for files with extension *.c or *.cpp or *.cc in a single find command using name. How to use an OR operator in find.?

find . -name '*.c' OR '*.cpp' OR '*.cc'

The exact syntax on how do i use it?

Upvotes: 1

Views: 95

Answers (2)

RedX
RedX

Reputation: 15165

Group them with \( \) (the slash is just to escape from the shell).

find . \( -iname bla -or -iname foo -or -name 'john dorian' \)

Upvotes: 1

phs
phs

Reputation: 11051

Interestingly

find . -name '*.c' -or -name '*.cpp' -or -name '*.cc'

Upvotes: 2

Related Questions