linux - Command to find the time difference -
i have log, dumped 1 or more process simultaneously. sometimes, because of cpu on load , context switching, logging file delayed. want find time difference between each line , print before each line?
log example:
07/18 16:20:29886564 pid= 2998,tid= 3036, xxxxx.c: 335:xxxxx:### xxxxxxxxxxxxxxxxxx ### 07/18 16:20:29886642 pid= 2998,tid= 3036, xxxxx.c: 484:xxxxx:### yyyyyyyyyyyyyyy() 07/18 16:20:29886880 pid= 2998,tid= 3036, xxxxx.c: 488:xxxxx:>>>yyyyyyyyyyyyy() 07/18 16:20:29887002 pid= 2998,tid= 3036, xxxxx.c: 494:xxxxx:>>>ok: zzzzzzzzzzzzzzz()
i suppose possible 'awk'. but, pretty bad @ linux commands. please this?
you can try following awk
command. have commented can understand how works:
awk '{ # split time field split($2,arr,":"); # convert hours , mins seconds , compute total curr=arr[3]+arr[2]*60+arr[1]*60*60; # set previous value first line if(prev == 0) prev=curr; # print out difference between current , previous totals print curr-prev,$0; # set previous current prev=curr; }' file
Comments
Post a Comment