If you want to use
rsync to recursively make the
dest directory an exact copy of the
rsync -a src/ dest
rsync man page explains how this works:
A trailing slash on the source […] avoid[s] creating an additional directory level at the destination. You can think of a trailing
/on a source as meaning “copy the contents of this directory” as opposed to “copy the directory by name” […]
🚀 Quick Start
rsync -av --exclude="path1/in/source" --exclude="path2/in/source" [source]/ [destination]
-avrwill create a new directory named
source/create different results:
source— copy the folder source into destination.
source/— copy the contents of source into destination.
- To exclude many files:
FILEis the name of a file containing other files or directories to exclude.
--excludemay also contain wildcards:
Modified from: https://stackoverflow.com/a/2194500/749232
Starting folder structure:
. ├── destination └── source ├── fileToCopy.rtf └── fileToExclude.rtf
rsync -av --exclude="fileToCopy.rtf" source/ destination
Ending folder structure:
. ├── destination │ └── fileToExclude.rtf └── source ├── fileToCopy.rtf └── fileToExclude.rtf
I find an alternative solution now.
rysnc -r /origin/* /target/ can sync all the contents from origin directory to target directory.