Reputation: 135
I want to write a command that will display all .c
and .cpp
files from my computer.
I know that I can use find with -name
but how can I concatenate the parms to find both file extensions.
Right now I have:
find -name "*.cpp"
Upvotes: 0
Views: 53
Reputation: 29932
Alternative solution
find -regex '.*\.\(c\|cpp\)'
In that way you can avoid multiple -o
logic condition (as you requested in HerrSerker answer
Upvotes: 2
Reputation: 33439
I guess
find -name "*.cpp" -o -name "*.c"
The -o
meaning LOGICAL OR
Upvotes: 1
Reputation: 290075
Use an OR expression with the -o
symbol:
find . -name "*.c" -o -name "*.cpp"
Depending on your system, you may need to escape the dot \.
to avoid it matching any character -> -name "*\.cpp"
.
Upvotes: 1