[英]How to exclude all but particular files from diff
I'm aware of how to exclude files from diff using the diff -x 'pattern' file1 file2
option. 我知道如何使用
diff -x 'pattern' file1 file2
选项从diff中排除文件。 But I intend to exclude ALL files, that don't match "pattern" (kind of an include option). 但是我打算排除所有不匹配“模式”(包含选项的类型)的文件。 Using an excluding regex didn't do the trick either:
使用排除的正则表达式也不能解决问题:
pak@idefix:~$ diff -r -x '^?!.*?\bpattern\b)*$' dir1 dir 2
I already checked the diff man-page but couldnt find something usefull, so some ideas would be great. 我已经检查了diff手册页,但是找不到有用的东西,因此有些想法很棒。
You can use find -iname
and diff -X
as find dir1 dir2 -iname 'pattern' -exec basename {} \\; | diff -r -X - dir1 dir2
您可以使用
find -iname
和diff -X
作为find dir1 dir2 -iname 'pattern' -exec basename {} \\; | diff -r -X - dir1 dir2
find dir1 dir2 -iname 'pattern' -exec basename {} \\; | diff -r -X - dir1 dir2
find dir1 dir2 -iname 'pattern' -exec basename {} \\; | diff -r -X - dir1 dir2
. find dir1 dir2 -iname 'pattern' -exec basename {} \\; | diff -r -X - dir1 dir2
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.