I have a text file that contains date, and two time-strings separated by spaces (a lot of these) in the format as given below:
2011-03-05 15:16:41 15:16:42
My question is this:
Using awk, how can I separate the time instants, assign them to variables and then subtract them? The answer to the above string would be something like:
2011-03-05 0:0:1
The text file is made up of a lot of lines of the above format.
I have gone through SO and see that there are a lot of date and time arithmetic questions, but none that would seem to fit to this particular requirement.
Any help is most welcome,
Sriram
Here is a simple awk script which does not use any time functions:
The input data:
Run it:
Alternatively, you can use
mktime: