Merge (combine) directories using rsync
5,135
rsync -avz LIB_COMMON/ LIB_CZ/ LIB_RESULT/ --delete-after
This will sync the content of lib_common/
& lib_cz/
to the lib_result/
folder.
Related videos on Youtube
Author by
jakoubekcz
Updated on September 18, 2022Comments
-
jakoubekcz over 1 year
I need to create a deploy script to combine the following directory structure:
├── LIB_COMMON │ ├── file1.php │ ├── file2.php │ ├── file3.php │ └── file4.php ├── LIB_CZ │ ├── file2.php │ ├── file3.php │ ├── file5.php │ └── file6.php
...which result should look like:
├── LIB_RESULT │ ├── file1.php ...with content from LIB_COMMON │ ├── file2.php ...from LIB_CZ │ ├── file3.php ...from LIB_CZ │ ├── file4.php ...from LIB_COMMON │ ├── file5.php ...from LIB_CZ │ └── file6.php ...from LIB_CZ
One way to do it is:
rsync LIB_COMMON/ LIB_RESULT/ --delete-after rsync LIB_CZ/ LIB_RESULT/
...but this will always transfer many files.
Other way could be:
cp LIB_COMMON/ TMP/ cp LIB_CZ/ TMP/ rsync TMP/ LIB_RESULT/ --delete-after
So, Does anyone know an elegant way to achieve this?
-
Admin almost 9 yearsThat depends; does the destination folder need to be able to sync back to the source folders?
-
Konrad Gajewski almost 9 yearsMemberów nawiewa...
-