Reputation: 161
I have a trouble with find command in Linux. In my makefile I have a variable in which I save all .c code files (I found this in the internet)
source_files = $(shell find ../src -type f -iname '*.c' | sed 's/^\.\.\/src\///')
But I want to add the additional extension - *.cu and *.cpp, not only *.c
For example:
source_files = $(shell find ../src -type f -iname **'*.c;*.cu;*.cpp'** | sed 's/^\.\.\/src\///')
Of course my code is not working.
How I can change the code to work with additional extensions?
Upvotes: 0
Views: 31
Reputation: 50064
You can chain search criteria together in find
with -o
:
source_files = $(shell find ../src -type f -iname '*.c' -o -iname '*.cu' -o -iname '*.cpp' | sed 's/^\.\.\/src\///')
You can also use regex search:
source_files = $(shell find ../src -type f -regex ".*\.\(c\|cu\|cpp\)$" | sed 's/^\.\.\/src\///')
Upvotes: 3