【发布时间】:2012-11-05 18:58:16
【问题描述】:
d我一直在尝试做与此非常相似的事情...Bash "diff" utility showing files as different when using a regex Ignore
并且已经做了几个小时但没有运气。
我确信 -I 选项不起作用。下面是使用另一个问题给出的示例进行的测试。
注意:我使用的是 RHEL6 附带的标准版本的 'diff',并且 -I 包含在手册页中,因此没有理由相信它不应该工作,但事实并非如此。任何帮助或指导将不胜感激
[toernerg@uschi12devwom27: ~] $ cat testfile1
// $Id: one
data
[toernerg@uschi12devwom27: ~] $ cat testfile2
// $Id: two
data
[toernerg@uschi12devwom27: ~] $ diff testfile1 testfile2
1c1
< // $Id: one
---
> // $Id: two
[toernerg@uschi12devwom27: ~] $ diff -I '.*\$\(Id\|Header\|Date\|DateTime\|Change\|File\|Revision\|Author\):.*\$.' testfile1 testfile2
1c1
< // $Id: one
---
> // $Id: two
[toernerg@uschi12devwom27: ~] $ diff --version
diff (GNU diffutils) 2.8.1
【问题讨论】:
-
格式输出不正确。让我尝试粘贴而不格式化...
-
您的示例输入文件在冒号后不包含文字
$。也许您不是要转义正则表达式中的$,而是想匹配行尾。