仅 rsync 报告已更新的文件
当 rsync 打印出它对每个文件执行的操作的详细信息(使用详细标志之一)时,它似乎包括已更新的文件和未更新的文件。例如,使用 -v
标志的输出片段如下所示:
rforms.php is uptodate
robots.txt is uptodate
sorry.html
thankyou.html is uptodate
我只对已更新的文件感兴趣。在上面的例子中,它是 sorry.html
。即使该目录中没有更新的文件,它也会在输入时打印出目录名称。有没有办法从此输出中过滤掉没有更新文件的最新文件和目录?
When rsync prints out the details of what it did for each file (using one of the verbose flags) it seems to include both files that were updated and files that were not updated. For example a snippet of my output using the -v
flag looks like this:
rforms.php is uptodate
robots.txt is uptodate
sorry.html
thankyou.html is uptodate
I'm only interested about the files that were updated. In the above case that's sorry.html
. It also prints out directory names as it enters them even if there is no file in that directory that is updated. Is there a way to filter out uptodate files and directories with no updated files from this output?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以通过 grep 进行管道传输:
You can pipe it through grep:
Rsync 的输出可以进行广泛的自定义,请查看 rsync --info=help;
-v
是从现代 rsync 获取信息的相当粗略的方法。就您而言,我不确定您认为“更新”的确切含义。例如,在接收器上也删除了?只有文件/目录,还有管道和符号链接?修改/访问时间还是仅内容?
作为一个简单的测试,我建议您查看:
rsync --info=name1
。Rsync's output can be extensively customized, take a look at
rsync --info=help
;-v
is a fairly coarse way to get information from a modern rsync.In your case, I'm not sure exactly what you consider "updated" to mean. For example, deleted on the receiver too? Only files/dirs, but also pipes and symlinks too? Mod/access times or only content?
As a simple test I suggest you look at:
rsync --info=name1 <other opts>
.这是我的看法...(经过工作验证并且对此非常满意。)
重要的是用于 itemize 的
-i
。grep 让所有 输出行通过(还有
-h --stats
中的任何摘要,以及之前的空行,这有利于易读性)例外 以点开头的文件:描述未更改的文件:Here's my take... (work-proven and very happy with it.)
The important bit is the
-i
for itemize.The grep lets all output lines pass (also any summary as in
-h --stats
, also empty ones before that, which benefits legibility) except those starting with a dot: These are the ones, that describe unchanged files: