I have a directory which has many sub-folders and under sub-folders there are other sub-folders. I want to copy all the directory and subdirectories into another location with copying only files with certain names in these directories (while preserving the hierarchy).
Let's say, copy all the directory and sub-directories, then if these directories have files with
.txt extensions, copy them too.
What is the best way to do this on a Unix/Linux system?