How to tar certain file types in all subdirectories?

Solution 1:

find ./someDir -name "*.php" -o -name "*.html" | tar -cf my_archive -T -

Solution 2:

If you're using bash version > 4.0, you can exploit shopt -s globstar to make short work of this:

shopt -s globstar; tar -czvf deploy.tar.gz **/Alice*.yml **/Bob*.json

this will add all .yml files that starts with Alice from any sub-directory and add all .json files that starts with Bob from any sub-directory.