0

How can one recursively copy all files of a specific pattern (*.tpl) using rsync?

Example:

/etc/test.tpl
/etc/dir/test.tpl
/etc/dir/**/test.tpl
1

1 Answer 1

0

One command that solves this is:

rsync --dry-run --verbose --recursive --relative --prune-empty-dirs --include="**/" --include="*.tpl" --exclude="*" /source /dest/
  • --relative: Recreate all parent folders.
  • --include="**/": The ** part allows recursion for folders (/).
  • --include="*.tpl": The pattern.
  • --exclude="*": Exclude the rest.

So far, we have included the whole folder structure, albeit with empty folders.

  • --prune-empty-dirs: Remove empty folders [from the list].

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.