Linux – How to tar certain file types in all subdirectories

linuxtar

I want to tar and all .php and .html files in a directory and its subdirectories. If I use

tar -cf my_archive *

it tars all the files, which I don't want. If I use

tar -cf my_archive *.php *.html

it ignores subdirectories. How can I make it tar recursively but include only two types of files?

Best Answer

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