I want to sync only specific files with rsync. I found:
rsync --include='SpecificFiles*' -f 'hide,! */' ~/src ~/dst
The "include" is obvious, but what does the "-f ..." part do? Thank you!
rsync --include='SpecificFiles*' -f 'hide,! */' ~/src ~/dst
First, the --include
tells rsync to copy everything matching SpecificFiles*
.
Second, the rule -f 'hide,! */'
hides all non-directories. This means that no regular file is copied unless it was matched by the previous include rule.
In more detail, hide,
starts a hide rule. Since */
matches all directories, its negation ! */
matches all non-directories. Thus, -f 'hide,! */'
hides all non-directories.
As an aside, hide is similar to exclude unless a delete option is also specified. In that case, if a file that was hidden is already at the destination, it will be deleted just as if it did not exist at the source. By contrast, if a file that was excluded is already at the destination, the destination file will not be deleted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With