不在 rsync 输出中显示目录

发布于 2024-12-22 01:34:43 字数 110 浏览 1 评论 0原文

有人知道是否有 rsync 选项,以便正在遍历的目录不会显示在标准输出上。

我正在同步音乐库,大量的目录使得很难看到哪些文件实际发生了变化。 我已经尝试过 -v 和 -i,但两者也显示目录。

Does anybody know if there is an rsync option, so that directories that are being traversed do not show on stdout.

I'm syncing music libraries, and the massive amount of directories make it very hard to see which file changes are actually happening.
I'v already tried -v and -i, but both also show directories.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

静谧幽蓝 2024-12-29 01:34:43

如果您在 rsync 命令中使用 --delete,则调用 grep -E -v '/$' 的问题是它将忽略如下信息行:

deleting folder1/
deleting folder2/
deleting folder3/folder4/

如果您正在进行备份并且远程文件夹已因 X 原因被完全清除,它也会清除您的本地文件夹,因为您看不到删除行。

要忽略已存在的文件夹但同时保留删除行,您可以使用以下表达式:

rsync -av --delete remote_folder local_folder | grep -E '^deleting|[^/]

If you're using --delete in your rsync command, the problem with calling grep -E -v '/$' is that it will omit the information lines like:

deleting folder1/
deleting folder2/
deleting folder3/folder4/

If you're making a backup and the remote folder has been completely wiped out for X reason, it will also wipe out your local folder because you don't see the deleting lines.

To omit the already existing folder but keep the deleting lines at the same time, you can use this expression :

rsync -av --delete remote_folder local_folder | grep -E '^deleting|[^/]

蹲墙角沉默 2024-12-29 01:34:43

我很想通过管道通过 grep -E -v '/$' 进行过滤,它使用行尾锚来删除以斜杠(目录)结尾的行。

这是我检查过的演示终端会话......

cefn@cefn-natty-dell:~$ mkdir rsynctest
cefn@cefn-natty-dell:~$ cd rsynctest/
cefn@cefn-natty-dell:~/rsynctest$ mkdir 1
cefn@cefn-natty-dell:~/rsynctest$ mkdir 2
cefn@cefn-natty-dell:~/rsynctest$ mkdir -p 1/first 1/second
cefn@cefn-natty-dell:~/rsynctest$ touch 1/first/file1
cefn@cefn-natty-dell:~/rsynctest$ touch 1/first/file2
cefn@cefn-natty-dell:~/rsynctest$ touch 1/second/file3
cefn@cefn-natty-dell:~/rsynctest$ touch 1/second/file4

cefn@cefn-natty-dell:~/rsynctest$ rsync -r -v 1/ 2
sending incremental file list
first/
first/file1
first/file2
second/
second/file3
second/file4

sent 294 bytes  received 96 bytes  780.00 bytes/sec
total size is 0  speedup is 0.00


cefn@cefn-natty-dell:~/rsynctest$ rsync -r -v 1/ 2 | grep -E -v '/

sending incremental file list
first/file1
first/file2
second/file3
second/file4

sent 294 bytes  received 96 bytes  780.00 bytes/sec
total size is 0  speedup is 0.00

I'd be tempted to filter using by piping through grep -E -v '/$' which uses an end of line anchor to remove lines which finish with a slash (a directory).

Here's the demo terminal session where I checked it...

cefn@cefn-natty-dell:~$ mkdir rsynctest
cefn@cefn-natty-dell:~$ cd rsynctest/
cefn@cefn-natty-dell:~/rsynctest$ mkdir 1
cefn@cefn-natty-dell:~/rsynctest$ mkdir 2
cefn@cefn-natty-dell:~/rsynctest$ mkdir -p 1/first 1/second
cefn@cefn-natty-dell:~/rsynctest$ touch 1/first/file1
cefn@cefn-natty-dell:~/rsynctest$ touch 1/first/file2
cefn@cefn-natty-dell:~/rsynctest$ touch 1/second/file3
cefn@cefn-natty-dell:~/rsynctest$ touch 1/second/file4

cefn@cefn-natty-dell:~/rsynctest$ rsync -r -v 1/ 2
sending incremental file list
first/
first/file1
first/file2
second/
second/file3
second/file4

sent 294 bytes  received 96 bytes  780.00 bytes/sec
total size is 0  speedup is 0.00


cefn@cefn-natty-dell:~/rsynctest$ rsync -r -v 1/ 2 | grep -E -v '/

sending incremental file list
first/file1
first/file2
second/file3
second/file4

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