I have a file of size 7GB. Now have two date time in that I want to use awk to get this difference of time between that two DateTime.
Below is how my files look like:
A B C D E
18/06/28 09:19:07 295 141536 18-06-28 09:17:47
18/06/28 09:20:07 268 1160 18-06-28 09:18:58
18/06/28 09:21:07 317 1454 18-06-28 09:19:47
18/06/28 09:22:07 275 1491 18-06-28 09:20:59
18/06/28 09:23:07 320 1870 18-06-28 09:21:07
18/06/28 09:24:07 310 1869 18-06-28 09:22:30
18/06/28 09:25:07 150 693 18-06-28 09:23:28
18/06/28 09:26:07 414 2227 18-06-28 09:24:34
I want the difference between (AB) – (E).
I tried this :
cat filename | awk -F " " '{print date -d ($1$2)-($5)}'
Output should be the time difference between the two datetime. Like for the first row difference will be 1min 20sec
Best Answer
Using GNU awk:
outputs
with perl, I'd use the DateTime ecosystem:
A much faster perl version, that does not require any non-core modules
or, alternate output: