我想获得两个htmls之间的差异。但是如果字符串中有一个名为my-attribute的属性,我想在计算diff时忽略my-attribute和它的值。与sed不能正常工作的差异
我使用diff实用程序来获取文件之间的差异。
下面的正则表达式在diff之外工作。
sed -E '[email protected](my-attribute)="[^"]*" @@g' html1.html
html1.html如下
<html>
<body>
<div>
<span my-attribute="8885" >html1</span>
</div>
</body>
</html>
但内部差异,如果我用同样的SED,这是给我一个语法错误
bash -c 'diff -y <(sed -E '[email protected](my-attribute)="[^"]*" @@g' html1.html) <(sed -E '[email protected](my-attribute)="[^"]*" @@g' html2.html)'
这给了错误: ('
将不胜感激任何帮助,以获得正确的命令。
编辑:添加html2.html
<html>
<body>
<div>
<span my-attribute="123" >html2</span>
</div>
</body>
</html>
@Inian添加html2.html – ConfusionPrevails