Linux mv 等效 rsync 命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9849794/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 05:23:00  来源:igfitidea点击:

mv equivalent rsync command

linuxbashrsyncmv

提问by Kokizzu

i'm trying to move folders to another folders using command line, with overwrite if already exists, but i got error "Is a directory" when using mv..

我正在尝试使用命令行将文件夹移动到另一个文件夹,如果已经存在则覆盖,但是在使用 mv.. 时出现错误“是目录”。

example:

例子:

mv src/test/ dest/

there are many files and folders on src/test/, there are also some files and some folders on dest/

src/test/上有很多文件和文件夹,dest/上也有一些文件和一些文件夹

and i want files and folders on dest/ replacedwith files and folder from src/test/ if exists, example:

我希望将 dest/上的文件和文件夹替换为 src/test/ 中的文件和文件夹(如果存在),例如:

src/test/bla/boo replaces dest/bla/boo
src/test/bla/bla/boo replaces dest/bla/bla/boo

also, everytime one file transfer completed, that one file deletedfrom src/test/

此外,每次完成一个文件传输,该文件从 src/test/ 中删除

and overall transfer progress barwould be fine..

整体转移进度条会很好..

what rsync flag should i use to make this happend?

我应该使用什么 rsync 标志来实现这一点?

采纳答案by Frédéric Hamidi

The following command line should achieve what you want:

以下命令行应该可以实现您想要的:

$ rsync -a --progress --remove-source-files src/test/ dest