I have a log file which contains execution start times and end times of various threads. I have done half the work, but I need some help to finish the other half. I wrote this command-
cat 2017-05-15.log | grep 'Executing ETL' | tr -s ' ' | cut -f2,3,4,5,8 -d' ' | sort -k5 -n
which produces the following output:
15 May 2017 03:43:40 696
15 May 2017 03:44:35 696
15 May 2017 03:45:02 696
15 May 2017 23:30:22 9502
15 May 2017 23:49:40 9502
15 May 2017 23:50:50 9502
15 May 2017 23:51:11 9502
15 May 2017 23:52:11 9502
15 May 2017 23:52:42 9502
15 May 2017 02:18:32 12795
15 May 2017 02:19:35 12795
15 May 2017 02:20:02 12795
15 May 2017 02:33:39 13674
15 May 2017 02:35:13 13674
15 May 2017 02:35:42 13674
15 May 2017 18:52:28 19143
15 May 2017 18:53:01 19143
15 May 2017 18:53:35 19143
15 May 2017 18:53:59 19143
15 May 2017 18:54:40 19143
This output is sorted on the process Id, which is the last column. The first occurence of each process Id is that process' start time, while the last occurrence is the end time of the same. I need to display only the first (start time) and last (end time) of each process. Like this:
15 May 2017 03:43:40 696
15 May 2017 03:45:02 696
15 May 2017 23:30:22 9502
15 May 2017 23:52:42 9502
15 May 2017 02:18:32 12795
15 May 2017 02:20:02 12795
15 May 2017 02:33:39 13674
15 May 2017 02:35:42 13674
15 May 2017 18:52:28 19143
15 May 2017 18:54:40 19143
The number of entries for each process id is not fixed. The output need not strictly be in this format. But I need to be able to clearly see the start and end times of each process.