【发布时间】:2021-06-28 21:25:21
【问题描述】:
我有 2 个文件,其中有一个与另一个文件不匹配的特定字符串。我需要使用diff -I RE <file1> <file2> 命令忽略该差异。
我从man diff找到这个
-I RE --ignore-matching-lines=RE
Ignore changes whose lines all match RE.
$cat 1.txt
MY_WORD
temp
abc
$cat 2.txt
YOUR_WORD
temp
abc
$diff -I MY_WORD 1.txt 2.txt
1c1
< MY_WORD
---
> YOUR_WORD
4d3
<
谁能帮我弄清楚为什么这不起作用? diff 不应在此处显示任何更改。
【问题讨论】:
-
为什么不应该呢? MY_WORD 仅在其中一个文件中具有特征。
Ignore changes whose lines **all** match RE. -
如果我需要忽略 2 个文件中的特定单词该怎么办?
-
看我的回答...