Created
September 29, 2021 09:13
-
-
Save zingbretsen/105d740e3bf9869bc7aa79d1a1319e84 to your computer and use it in GitHub Desktop.
Includes and excludes in rsync
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -eux | |
# Copies whole src dir into dest | |
rsync -avz src dest/ | |
# Copies content of src dir into dest | |
rsync -avz src/ dest/ | |
# Copies all files/directories except those specified exactly or with wildcard | |
rsync -avz --exclude='.gitignore' --exclude='*csv' --exclude='d2' src/ dest/ | |
# Copies only .txt files | |
# Includes all directories, includes .txt files, then excludes all else | |
rsync -avz --include='*/' --include='*txt' --exclude='*' src/ dest/ | |
# Copies nothing | |
# Order of arguments matters. This excludes all files at the start | |
# and so nothing is copied | |
rsync -avz --exclude='*' --include='*/' --include='*txt' src/ dest/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment