我想复制目录中的所有文件,除了特定子目录中的某些文件。
我注意到cp
命令没有--exclude
选项。
那么,我怎样才能实现这一目标呢?
rsync
快速且简单:
rsync -av --progress sourcefolder /destinationfolder --exclude thefoldertoexclude
您可以使用--exclude
多次。
rsync -av --progress sourcefolder /destinationfolder --exclude thefoldertoexclude --exclude anotherfoldertoexclude
请注意,目录thefoldertoexclude
after --exclude
选项是相对于sourcefolder
, i.e., sourcefolder/thefoldertoexclude
.
您还可以添加-n
进行空运行,以在执行实际操作之前查看将复制的内容,如果一切正常,则删除-n
从命令行。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)