我想獲得兩個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