How can I recursively copy files by file extension, preserving directory structure?
You can use find and cpio to do this
cd /top/level/to/copy
find . -name '*.txt' | cpio -pdm /path/to/destdir
(-updm for overwrite destination content.)
cd /source/path
find -type f -name \*.txt -exec install -D {} /dest/path/{} \;
Another approach
find . -name '*.txt' -exec rsync -R {} path/to/dext \;