Skip to content
Advertisement

Comparing epoch timestamps in a log and checking if x time has elapsed between the previous and current timestamp in the list

I have a log file consisting of a list of epoch 19-digit timestamps, for example

JavaScript

I would like to iterate through this list, and compare the previous timestamp to the current timestamp in the list and echo a message if x duration of inactivity as occurred, ex:

JavaScript

What would be the most efficient method to iterate through the list such that the current timestamp becomes the previous time stamp, and so forth, until I reach the end of the list?

Many thanks

Advertisement

Answer

I suggest this simple awk for this:

JavaScript
JavaScript

You can tune your desired value of delta in argument.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement