I am currently working on analyzing the performance of an application. I've starting by looking at the logs generated by our application and identifying the business logic tasks that are taking more than acceptable time to execute. A snippet from the log file looks something like :2014-07-02 18:03:20,269 INFO  [ROOT] - Task1. xmlRecord Id :35165 processed2014-07-02 18:05:20,269 INFO  [ROOT] - Task1. xmlRecord Id :35162 processed2014-07-02 18:15:20,269 INFO  [ROOT] - Task1. xmlRecord Id :35164 processed2014-07-02 18:20:20,269 INFO  [ROOT] - Task2. xmlRecord Id :35165 processedMy requirement is to find the total amount of time spent on executing each task. For instance, the amount of time spent on Task2 for xmlRecord 35165 = End time for Task 2 for xmlRecord 35165 - End Time for Task 1 for xmlRecord 35165. For this reason, I want a way to group all the log statements that have the same xmlRecord Id to be grouped together as shown below :2014-07-02 18:03:20,269 INFO  [ROOT] - Task1. xmlRecord Id :35165 processed2014-07-02 18:20:20,269 INFO  [ROOT] - Task2. xmlRecord Id :35165 processed2014-07-02 18:05:20,269 INFO  [ROOT] - Task1. xmlRecord Id :35162 processed2014-07-02 18:15:20,269 INFO  [ROOT] - Task1. xmlRecord Id :35164 processedIf I can group all the log statements as shown above, I will quickly be able to see that it took Task2 17 minutes to process xmlRecord 35165. Note that the logs that I have shown here are not the exact logs that my application prints but just a sample. I want to be able to group all log statements such that logs for a particular XML id are always one after another. I'm a bit rusty with the shell and would appreciate it if someone can point me to a one liner or a script that already does this so I don't waste time reinventing the wheel.
Printing lines with similar text together
shell script;text processing;sort