仅 rsync 报告已更新的文件

发布于 2024-08-14 12:27:40 字数 322 浏览 1 评论 0原文

当 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

尤怨 2024-08-21 12:27:40

您可以通过 grep 进行管道传输:

rsync -vv (your other rsync options here) | grep -v 'uptodate'

You can pipe it through grep:

rsync -vv (your other rsync options here) | grep -v 'uptodate'
枫以 2024-08-21 12:27:40

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>.

凉宸 2024-08-21 12:27:40

这是我的看法...(经过工作验证并且对此非常满意。)

rsync -arzihv --stats --progress   \
    /media/frank/foo/              \
    /mnt/backup_drive/    | grep -E '^[^.]|^

重要的是用于 itemize 的 -i

grep 让所有 输出行通过(还有-h --stats 中的任何摘要,以及之前的空行,这有利于易读性)例外 以点开头的文件:描述未更改的文件

A . means that the item is not being updated  (though  it
    might have attributes that are being modified).

重要的是用于 itemize 的 -i

grep 让所有 输出行通过(还有-h --stats 中的任何摘要,以及之前的空行,这有利于易读性)例外 以点开头的文件:描述未更改的文件

Here's my take... (work-proven and very happy with it.)

rsync -arzihv --stats --progress   \
    /media/frank/foo/              \
    /mnt/backup_drive/    | grep -E '^[^.]|^

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:

A . means that the item is not being updated  (though  it
    might have attributes that are being modified).

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:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文