LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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, 03: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, 10:56 AM   #2
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 497

Rep: Reputation: 188Reputation: 188
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, 11:01 AM   #3
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,116

Rep: Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530
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 11:02 AM.
 
  


Reply

Tags
rsync


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 04:57 AM
rsync option question digitolx Linux - Software 3 04-26-2010 01:25 PM
rsync option in cygwin ufmale Linux - Newbie 2 01-25-2009 01:06 PM
rsync with -d option tate_harmann Linux - Newbie 2 09-20-2006 02:58 PM
Using the exclude option absolutely with rsync karlovac Programming 0 03-01-2004 01:39 PM


All times are GMT -5. The time now is 02:08 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration