Skip to content
Advertisement

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. And a complete.txt file, which denotes all files in data and opt are correct. I need to copy folder A completely. But the complete.txt file should copy only after all other files and folders are copied.

Is there any linux command to do this.

Advertisement

Answer

Using rsync you can easily achieve it. 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.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement