[英]Using sed\awk to display timestamp different between two consequetive lines
I have a log file displays lines like the following:我有一个日志文件显示如下行:
7,5580,70930902,-;2c04000.vdi-ch0: start
7,5580,70930902,-;2c04000.vdi-ch0: 开始
7,5621,70958680,-;2c04000.vdi-ch0: start7,5621,70958680,-;2c04000.vdi-ch0: 开始
7,5662,70986453,-;2c04000.vdi-ch0: start7,5662,70986453,-;2c04000.vdi-ch0: 开始
7,5703,71014240,-;2c04000.vdi-ch0: start7,5703,71014240,-;2c04000.vdi-ch0: 开始
the third value after the seconad comma (70930902, 70958680...) is a timestamp.第二个逗号后的第三个值(70930902、70958680...)是时间戳。 I would like to display at the end of each line the difeerent between two consequetive timestamps.
我想在每行的末尾显示两个连续时间戳之间的差异。 Can you please help me to figure out how to do that?
你能帮我弄清楚怎么做吗?
I'm a little new with all of the sed\awk stuff, so any detaled answer will be appriciated.我对所有 sed\awk 的东西都有点陌生,所以任何详细的答案都会被应用。
Thanks谢谢
Rachel雷切尔
Finally I managed to write a command:最后我设法写了一个命令:
awk -F',' '{print NR,$0,"diff = ",a-$3}{a=$3}'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.