Linux   发布时间:2022-04-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了使rsync排除包含具有特定名称的文件的所有目录大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

我希望rsync排除包含具有特定名称的文件的所有目录,例如“.rsync-exclude”,与“.rsync-exclude”文件的内容无关. 如果文件“.rsync-exclude”只包含“*”,我可以使用rsync -r SRC DEST –filter =’dir-merge, – .rsync-exclude’. 但是,应该排除目录,而不依赖于“.rsync-exclude”文件的内容(至
我希望rsync排除包含具有特定名称文件的所有目录,例如“.rsync-exclude”,与“.rsync-exclude”文件内容无关.

如果文件“.rsync-exclude”只包含“*”,我可以使用rsync -r SRC DEST –filter =’dir-merge,– .rsync-exclude’.

但是,应该排除目录,而不依赖于“.rsync-exclude”文件内容(至少应该可以将“.rsync-exclude”文件留空).

有任何想法吗?

解决方法

rsync不支持这个(至少manpage没有提到任何内容),但你可以分两步完成:

>运行find以查找.rsync-exclude文件
>将此列表传递给–exclude-from(或使用临时文件)

--exclude-from=FILE
      This option is related to the --exclude option,but it specifies a FILE that contains exclude  patterns
      (one per linE).  Blank lines in the file and lines starTing with ';' or '#' are ignored.  If FILE is -,the list will be read from standard input.

或者,如果你不介意在文件中放一些东西,你可以使用:

-F     The -F option is a shorthand for adding two --filter rules to your command.  The first time it is  used
          is a shorthand for this rule:

             --filter='dir-merge /.rsync-filter'

          This  tells  rsync  to  look for per-directory .rsync-filter files that have been sprinkled through the
          hierarchy and use their rules to filter the files in the transfer.  If -F is repeated,it is  a  short-
          hand for this rule:

             --filter='exclude .rsync-filter'

          This filters out the .rsync-filter files themselves from the transfer.

          See the FILTER RULES section for detailed information on how these options work.

大佬总结

以上是大佬教程为你收集整理的使rsync排除包含具有特定名称的文件的所有目录全部内容,希望文章能够帮你解决使rsync排除包含具有特定名称的文件的所有目录所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。