简体   繁体   English

仅在复制所有目录后复制文件

[英]Copy file only after all directories are copied

I have a folder A. It contains another folders data and opt, which contains many folders and files. 我有一个文件夹A。它包含另一个文件夹数据和opt,其中包含许多文件夹和文件。 And a complete.txt file, which denotes all files in data and opt are correct. 还有complete.txt文件,它表示data和opt中的所有文件都是正确的。 I need to copy folder A completely. 我需要完全复制文件夹A。 But the complete.txt file should copy only after all other files and folders are copied. 但是complete.txt文件应该仅在复制所有其他文件和文件夹之后才复制。

Is there any linux command to do this. 是否有任何linux命令可以执行此操作。

Using rsync you can easily achieve it. 使用rsync可以轻松实现它。 But It takes two steps 但这需要两个步骤

$rsync -av --progress sourcefolder destinationfolder --exclude filetoexclude
$rsync -av --progress sourcefolder destinationfolder

When you use rsync with exclude option, it will exclude the particular file and when you use it next time without exclude it will only copy the excluded file. 当您将rsync与exclude选项一起使用时,它将排除特定文件,而在下次不排除使用它时,它将仅复制排除的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM