Take a look at rsync . Assuming you are in '/',
rsync -rf/ g/ --include "*/" --include "*/file.txt" --exclude "*"
First of all, you need to specify rsync for viewing inside subdirectories (and counteract the last exception). The second involves selecting the files you want to copy. An exclude ensures that other files are not processed in / f, which do not have the required template.
Note. If you have symbolic links, rsync will copy the link, not the file the link points to, unless you specify --copy-links .
Example:
$ find fg -type f f/f1/file.txt f/f1/fileNew.txt f/f2/file.txt f/f3/file.txt find: g: No such file or directory $ rsync -rf/ g/ --include "*/" --include "*/file.txt" --exclude "*" $ find fg -type f f/f1/file.txt f/f1/fileNew.txt f/f2/file.txt f/f3/file.txt g/f1/file.txt g/f2/file.txt g/f3/file.txt
source share