2014-07-20 34 views
0

請原諒我的新手問題。Rsync/Linux:阻止在目標目錄中創建新目錄

關於Rsync使用的問題。 如果我指定,作爲一個例子,該命令:

rsync -av Downloads Downloads2 

結果是目錄「Downloads2」與「下載」作爲子目錄,並且創建的內/ Downloads2 /下載是全部內容原始/ Downloads目錄。

我想知道是否有一個選項會導致rsync複製/ Downloads下載到/ Downloads2而不創建/ Downloads2/Downloads結構?

回答

1

你可以從「人rsync的」看,在源目錄添加尾隨斜線將防止該目錄中創建:

  rsync -avz foo:src/bar/ /data/tmp 

    A trailing slash on the source changes this behavior to avoid 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", but in both cases the 
    attributes of the containing directory are transferred to the contain‐ 
    ing directory on the destination. In other words, each of the follow‐ 
    ing commands copies the files in the same way, including their setting 
    of the attributes of /dest/foo: 

      rsync -av /src/foo /dest 
      rsync -av /src/foo/ /dest/foo