I am creating a shell scrip to store the output of the traceroute
command with a user-entered input to a file.
I want to extract the latency for each packet and each router and find the min, max and average times for each packet.
If this is the output of traceroute
:
1 176.221.87.1 (176.221.87.1) 1.474 ms 1.444 ms 1.390 ms
2 f126.broadband2.quicknet.se (92.43.37.126) 10.047 ms 19.868 ms 23.156 ms
3 10.5.12.1 (10.5.12.1) 24.098 ms 24.340 ms 25.311 ms
I need to find the max of all latency for the first packet, which is in this case 24.098 ms
. Similarly min is 1.474
and average for the first packet is 11.873 ms
. I need to do this for each packet.
I want output like:
1 176.221.87.1 (176.221.87.1) 1.474 ms 1.444 ms 1.390 ms
2 f126.broadband2.quicknet.se (92.43.37.126) 10.047 ms 19.868 ms 23.156 ms
3 10.5.12.1 (10.5.12.1) 24.098 ms 24.340 ms 25.311 ms
For the first packet:
Minimum: 1.474 ms
Maximum: 24.098 ms
Average: 11.873 ms
.
.
and so on.
I am not able to come up with an awk statement to do this. Perhaps there is another way?
Any inputs would be really helpful.