我必须进行文件比较,但我希望您排除注释 现在它给了我这样的结果。
目前我正在使用:
diff -b -B [patch] [patch]
这让我:
< #<Location /bancochile>
< # WeblogicHost bgri.wls.ri
< # WeblogicPort 20015
< # SetHandler weblogic-handler
< #</Location>
<
45c39,43
答案 0 :(得分:2)
我建议用bash:
diff -b -B <(grep -v '^#' patch1) <(grep -v '^#' patch2)
答案 1 :(得分:2)
根据建议https://book.cakephp.org/3.0/en/development/routing.html#prefix-routing,GNU diff
明确支持此目的:
diff -I '^[[:space:]]*[#]' -b -B old.cfg new.cfg
也就是说,如果你只是想知道是否有变化,那么使用cmp
会更有效率:
if cmp -s <(grep -E -v '^[[:space:]]*[#]' <old.cfg) \
<(grep -E -v '^[[:space:]]*[#]' <new.cfg); then
echo "Excluding comments, these files are identical"
fi