LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   rsync --del option (https://www.linuxquestions.org/questions/linux-newbie-8/rsync-del-option-4175555070/)

mangeshs 10-02-2015 02:23 AM

rsync --del option
 
Hello LQites

What is the difference between:

1) rsync -av --del /dir_one /dir_two
and
2) rsync -av --del /dir_one/ /dir_two

Does option 1 delete all data on the destination folder /dir_two if directory /dir_one does not exist on /

Thank you.

MS

cliffordw 10-02-2015 09:56 AM

Hi there,

The best way to learn is to just try it yourself :-)

If /dir_one doesn't exist, the command will fail BEFORE deleting anything, so --del has no effect in that case, and behaves no differently in these 2 cases.

The only difference between the two commands is in what the destination directory structure will look like.

If /dir_one contains file_three, the first command will result in /dir_two/dir_one/file_three, while the second command will result in /dir_two/file_three.

Regards,

Clifford

szboardstretcher 10-02-2015 10:01 AM

test it out.

Code:

cd
mkdir /dir_one /dir_two
touch /dir_one/file1
touch /dir_one/file2
rsync -av --del /dir_one /dir_two
cd /dir_two
ls -alh
# look at the results

Code:

cd
rm -rf /dir_one /dir_two
mkdir /dir_one /dir_two
touch /dir_one/file1
touch /dir_one/file2
rsync -av --del /dir_one/ /dir_two
cd /dir_two
ls -alh
# look at the results

Code:

cd
rm -rf /dir_one /dir_two
mkdir /dir_one /dir_two
touch /dir_one/file1
touch /dir_one/file2
rsync -av --del /dir_one/ /dir_two
rm -rf /dir_one/file2
rsync -av --del /dir_one/ /dir_two
cd /dir_two
ls -alh
# look at the results



All times are GMT -5. The time now is 06:06 AM.