Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Sorting a text file with respect to Function/Keyword

$
0
0
Hello Experts,

I am truly a beginner in shell and perl . Need an urgent help with sorting a file. please help. wouldn't mind whether in perl or shell script.

Here are the details.
Code:

------------------------------------------------------
 Input Text file EX:
------------------------------------------------------

There is one ENTRY & EXIT for each function/Thread but it may not be sequential. The input file is time sequential.

Code:

|TIME|THREAD_ID:3086054296|dtcp_Init|ENTRY|13:16:825897777:635006|
|TIME|THREAD_ID:3086054296|dtcp_Init|EXIT|13:16:825897777:695502|

|TIME|THREAD_ID:3086063296|cc_SockRecvBuffer|ENTRY|13:16:825897777:863804|
|TIME|THREAD_ID:3086063296|cc_SockRecvBuffer|EXIT|13:16:825897777:864584|

|TIME|THREAD_ID:3086067592|CC_SendAndRecieveMessage|ENTRY|13:16:825897777:159307|
|TIME|THREAD_ID:3086067592|http_SendMessage|ENTRY|13:16:825897777:159499|

|TIME|THREAD_ID:3086067592|http_TimeOut|ENTRY|13:16:825897777:160185|
|TIME|THREAD_ID:3086067592|http_TimeOut|EXIT|13:16:825897777:160379|

|TIME|THREAD_ID:3086067592|http_SendMessage|EXIT|13:16:825897777:161849|
|TIME|THREAD_ID:3086067592|CC_SendAndRecieveMessage|EXIT|13:16:825897777:191158|

Output
-------------------------
Output file should be sorted on ENTRY & EXIT of a function irrespective of time sequence.
For ex the above input lines should be output as follows

Code:

|TIME|THREAD_ID:3086054296|dtcp_Init|ENTRY|13:16:825897777:635006|
|TIME|THREAD_ID:3086054296|dtcp_Init|EXIT|13:16:825897777:695502|

|TIME|THREAD_ID:3086063296|cc_SockRecvBuffer|ENTRY|13:16:825897777:863804|
|TIME|THREAD_ID:3086063296|cc_SockRecvBuffer|EXIT|13:16:825897777:864584|

|TIME|THREAD_ID:3086067592|CC_SendAndRecieveMessage|ENTRY|13:16:825897777:159307|
|TIME|THREAD_ID:3086067592|CC_SendAndRecieveMessage|EXIT|13:16:825897777:191158|

|TIME|THREAD_ID:3086067592|http_TimeOut|ENTRY|13:16:825897777:160185|
|TIME|THREAD_ID:3086067592|http_TimeOut|EXIT|13:16:825897777:160379|

|TIME|THREAD_ID:3086067592|http_SendMessage|ENTRY|13:16:825897777:159499|
|TIME|THREAD_ID:3086067592|http_SendMessage|EXIT|13:16:825897777:161849|


Attached Files
File Type: txt timeprofile_log.txt (81.1 KB)

Viewing all articles
Browse latest Browse all 16232

Trending Articles