作者:欣欣2602916441 | 来源:互联网 | 2023-10-10 14:22
Imtryingtowritealinuxdiffstatementtoignorealllinedifferencesthathavealiteralstring
I'm trying to write a linux diff statement to ignore all line differences that have a literal string somewhere in them. (In my case I want to ignore lines with url differences.)
我正在尝试编写一个linux diff语句来忽略在其中某处有文字字符串的所有行差异。 (在我的情况下,我想忽略带有url差异的行。)
Currently I've tried
目前我已经尝试过了
diff -I '^insert.*' file1.txt file2.txt > outputDiff.txt
The output here took out lines that started with insert, so that's a step in the right direction, but I need to remove a longer string literal (url) with lots of periods and slashes.
这里的输出取出了以insert开头的行,所以这是向正确方向迈出的一步,但我需要删除一个带有大量句点和斜杠的较长字符串文字(url)。
To be exact: I need to look for lines that have:
确切地说:我需要查找具有以下内容的行:
ta.com/nmo/nmdr/templates/nmdr.css\
somewhere in them, and exclude them from the diff result.
在它们的某个地方,并将它们从diff结果中排除。
How do I look for a literal string with a regex that will work within a diff -I statement? (Include the start of the line and the end of the line if it's needed for my diff statement)
如何查找带有可在diff -I语句中使用的正则表达式的文字字符串? (如果我的diff语句需要,则包括行的开头和行的结尾)
2 个解决方案