LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-02-2015, 02:23 AM   #1
mangeshs
LQ Newbie
 
Registered: Jul 2014
Posts: 4

Rep: Reputation: Disabled
Unhappy 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
 
Old 10-02-2015, 09:56 AM   #2
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
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
 
Old 10-02-2015, 10:01 AM   #3
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
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

Last edited by szboardstretcher; 10-02-2015 at 10:02 AM.
 
  


Reply

Tags
rsync



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rsync --timeout option not working timsoft Slackware 2 04-14-2015 03:57 AM
rsync option question digitolx Linux - Software 3 04-26-2010 12:25 PM
rsync option in cygwin ufmale Linux - Newbie 2 01-25-2009 12:06 PM
rsync with -d option tate_harmann Linux - Newbie 2 09-20-2006 01:58 PM
Using the exclude option absolutely with rsync karlovac Programming 0 03-01-2004 12:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration