the First occurrence of <time> for <Job Name> is starting time
the Fourth occurrence of <time> for <Job Name> is end time of that job
i want to calculate the difference between start time and end time for all the jobs
Note : Every job has exactly 4 entries where 1st entry denotes start time and 4th denotes the end time , there is no rule that all the four occurrences are consecutive
i have tried the
awk 'x[$2,$5]++' FS=" " file.txt
i dont know how to catch each occurrences to variables so that we can process in script
---------- Post updated at 03:19 PM ---------- Previous update was at 02:50 PM ----------
can anyone please explain the below multi dimensional array (if am not wrong) , i tried but could not get exactly how its working
Times[$5,++Job[$5]] = $2;
Job[] uses Jobname as an index and counts how many lines have been seen for a job sofar.
Times[] has and index of JobName + Line sequence (from Job[]) and stores the Time value (field 2).
When processing line 6 of your input file the arrays will be as follows: