如何使该 rsync 命令成为非递归命令?

如何使该 rsync 命令成为非递归命令?
rsync -avi --delete --modify-window=1 --no-perms --no-o --no-g
    ~/Documents/Stuff/ /media/user/PC/Stuff;;

即不从源目录复制子目录?

答案1

您可以--exclude='*/'向 rsync 选项添加选项以防止同步目录。

答案2

摘自man rsync

    -a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)

-a 意味着-r 你可以:

 remove `-a --no-perms --no-o --no-g ` and replace by `-ltD`

或者

 add `--no-recursive`       

--delete增加更多的复杂性,从man rsync

--删除`

Prior to rsync 2.6.7, this option would have no effect unless --recursive was enabled.  
Beginning with 2.6.7, deletions will also occur when --dirs (-d) is  enabled,  but  only  for  directories whose contents are being copied.

所以你必须使用--dirs

相关内容