gpt4 book ai didi

unix - 如何忽略以带有差异的字符串开头的行?

转载 作者:行者123 更新时间:2023-12-04 03:24:17 25 4
gpt4 key购买 nike

如何区分两个文件并忽略以序列开头的行。

例如

File1:
abc
def
time:123

File2:
igh
def
time:345

使用 unix diff 它将报告
<time:123
>time:345

我想忽略这个差异。有任何想法吗?

最佳答案

怎么样:diff -I '^time.*' file1 file2 ?
请不要它doesn't always work as expected根据 diffutils 手册:

However, -I only ignores the insertion or deletion of lines that contain the regular expression if every changed line in the hunk (every insertion and every deletion) matches the regular expression.

In other words, for each non-ignorable change, diff prints the complete set of changes in its vicinity, including the ignorable ones. You can specify more than one regular expression for lines to ignore by using more than one -I option. diff tries to match each line against each regular expression, starting with the last one given.

关于unix - 如何忽略以带有差异的字符串开头的行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2747091/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com