I'm trying to create a compressed tarball that contains all PDF files that exist in one of my directories. The directory structure needs to be retained. Empty directories are not needed, but I really don't care if they're there.
For example, say I had a directory that looked like this:
dir dir/subdir1 dir/subdir1/subsubdir1/song.mp3 dir/subdir2 dir/subdir2/subsubdir1 dir/subdir2/subsubdir1/document.pdf dir/subdir2/subsubdir1/another-song.mp3 dir/subdir2/subsubdir1/top-ten-movies.txt dir/subdir3 dir/subdir3/another-document.pdf
After running the command, I'd like to have
dir.tar.gz contain this:
dir dir/subdir2 dir/subdir2/subsubdir1 dir/subdir2/subsubdir1/document.pdf dir/subdir3 dir/subdir3/another-document.pdf