我有很多日志想要比较。问题是,一行中的前几个字符是时间戳。如何比较日志,忽略时间戳。
例如,这两个应该是相同的:
httpd:debug:64.715:rutWan_getIpOrPppObjectByIfname:2124:looking for eth1
httpd:debug:64.717:rutWan_getIpOrPppObjectByIfname:2134:found WanIPConnection object
httpd:debug:64.719:odl_setObjectExternal:463:starting external set of WANIPConnection iidStack={3,1,6}
httpd:debug:64.719:rcl_wanIpConnObject:178:Entered
httpd:debug:64.719:rutCfg_tearDownWanIpConnection:365:Enter.
httpd:debug:64.719:rutWl2_getL2LinkObj:122:Enter.
和:
httpd:debug:328.628:rutWan_getIpOrPppObjectByIfname:2124:looking for eth1
httpd:debug:328.630:rutWan_getIpOrPppObjectByIfname:2134:found WanIPConnection object
httpd:debug:328.632:odl_setObjectExternal:463:starting external set of WANIPConnection iidStack={3,1,6}
httpd:debug:328.632:rcl_wanIpConnObject:178:Entered
httpd:debug:328.632:rutCfg_tearDownWanIpConnection:365:Enter.
httpd:debug:328.632:rutWl2_getL2LinkObj:122:Enter.
编辑:httpd 部分也可能有所不同,因为它是从库中调用该函数的进程的名称。
答案1
您可以使用cut
它来摆脱时间戳“列”
cat logfile | cut -d":" -f1,2,4- > logfile_notimestamp
如果您对两个文件都执行此操作,则可以使用 diff 轻松比较它们。