How to tar specific file extension files?

Viewed 2044

I have file types .cpp,.h,.o,.so,*.a I need to tar only *.cpp and .h files. as of now i am using --exclude=.{o,so,a} unwanted files to tar. but if i have many unwanted extensions the exclude list comes very big. what is the command to include specific file extensions to tar?

1 Answers
 find -name "*.h" -o -name "*.cpp" | xargs tar -czvf build.tar.gz
Related