Help needed in sorting

Hi, Please I need urgent help in sorting below data, I had similar post but there was a kind of space in between the data but now there is no space and I have tried adjusting the old script to work but it didn't.
here are the data;

traceroute to 2001:1ba0:2a0:5965:0:30:24:1 (2001:1ba0:2a0:5965:0:30:24:1), 30 hops max, 80 byte packets
 1  2001:630:301:1100::2  0.491 ms
 2  2001:630:301:7005::1  1.173 ms
 3  2001:630:302:c01::feed:1  1.182 ms
 4  2001:630:302:705::feed:1  1.710 ms
 5  2001:630:0:8045::601  3.087 ms
 6  2001:630:0:10::3e  6.241 ms
 7  2001:630:0:10::9a  6.539 ms
 8  2001:630:0:10::152  6.546 ms
 9  2001:7f8:4::7218:1  34.788 ms
10  2001:4de8:d1a1:1111:4::1  34.802 ms
11  2001:4de8:d1a1:1111:1f::2  34.641 ms
12  2001:4de8:d1a1:1111:11::2  39.970 ms
13  2001:1ba0:babe::1:2  40.120 ms
14  2001:1ba0:2a0:5965:0:30:24:1  40.136 ms
traceroute to 2001:8a8:21:5:216:3eff:fec1:423 (2001:8a8:21:5:216:3eff:fec1:423), 30 hops max, 80 byte packets
 1  2001:630:301:1100::2  0.674 ms
 2  2001:630:301:7005::1  0.866 ms
 3  2001:630:302:c01::feed:1  0.833 ms
 4  2001:630:302:705::feed:1  16.440 ms
 5  2001:630:0:8045::601  3.091 ms
 6  2001:630:0:10::3e  6.226 ms
 7  2001:630:0:10::9a  6.509 ms
 8  2001:630:0:10::152  6.516 ms
 9  2001:7f8:4::32e6:1  6.520 ms
10  2001:1620:2::9a  23.761 ms
11  2001:1620:2::8d  28.410 ms
12  2001:1620:2::1  28.392 ms
13  2001:7f8:24::f  28.539 ms
14  2001:8a8:1:2::30  28.545 ms
15  2001:8a8:1:b::74  28.670 ms
16  2001:8a8:21:5:216:3eff:fec1:423  28.642 ms
traceroute to 2a00:ec8:401:1:a032::1 (2a00:ec8:401:1:a032::1), 30 hops max, 80 byte packets
 1  2001:630:301:1100::2  0.928 ms
 2  2001:630:301:7005::1  0.743 ms
 3  2001:630:302:c01::feed:1  0.708 ms
 4  2001:630:302:705::feed:1  1.412 ms
 5  2001:630:0:8045::601  2.962 ms
 6  2001:630:0:10::3e  6.082 ms
 7  2001:630:0:10::8e  6.414 ms
 8  2001:798:28:10aa::1  6.667 ms
 9  2001:798:cc:2201:2801::1  14.741 ms
10  2001:798:cc:1401:2201::1  22.125 ms
11  2001:450:2002:70::1  22.243 ms
12  2001:450:2002:1ef::2  22.056 ms
13  2a00:ec8:401:211::1  22.180 ms
14  2a00:ec8:401:1:a032::1  22.346 ms
traceroute to 2001:470:895b::3 (2001:470:895b::3), 30 hops max, 80 byte packets
 1  2001:630:301:1100::2  5.884 ms
 2  2001:630:301:7005::1  0.876 ms
 3  2001:630:302:c01::feed:1  0.888 ms
 4  2001:630:302:705::feed:1  14.965 ms
 5  2001:630:0:8045::601  3.035 ms
 6  2001:630:0:10::3e  6.340 ms
 7  2001:630:0:10::9a  6.352 ms
 8  2001:630:0:10::152  6.580 ms
 9  2001:7f8:4::1b1b:1  6.766 ms
10  2001:470:0:3e::1  74.825 ms
11  2001:470:0:5d::2  77.773 ms
12  2001:470:895b::3  110.466 ms
traceroute to 2a00:ec8:401:1:a043::1 (2a00:ec8:401:1:a043::1), 30 hops max, 80 byte packets
 1  2001:630:301:1100::2  0.524 ms
 2  2001:630:301:7005::1  0.908 ms
 3  2001:630:302:c01::feed:1  0.915 ms
 4  2001:630:302:705::feed:1  1.462 ms
 5  2001:630:0:8045::601  3.202 ms
 6  2001:630:0:10::3e  6.205 ms
 7  2001:630:0:10::8e  6.612 ms
 8  2001:798:28:10aa::1  6.624 ms
 9  2001:798:cc:2201:2801::1  14.753 ms
10  2001:798:cc:1401:2201::1  22.057 ms
11  2001:450:2002:70::1  22.197 ms
12  2001:450:2002:1ef::2  22.012 ms
13  2a00:ec8:401:211::1  22.156 ms
14  2a00:ec8:401:1:a043::1  22.456 ms
traceroute to 2a02:750:0:501::102 (2a02:750:0:501::102), 30 hops max, 80 byte packets
 1  2001:630:301:1100::2  0.465 ms
 2  2001:630:301:7005::1  0.824 ms
 3  2001:630:302:c01::feed:1  0.832 ms
 4  2001:630:302:905::feed:1  2.142 ms
 5  2001:630:0:8040::601  4.904 ms
 6  2001:630:0:10::9a  74.637 ms
 7  2001:630:0:10::152  5.247 ms
 8  2001:7f8:4::1b1b:1  13.528 ms
 9  2001:470:0:3f::2  16.631 ms
10  2001:470:0:47::2  20.289 ms
11  2001:470:0:110::2  44.832 ms
12  2001:7f8:3e:0:a500:4:3948:1  53.290 ms
13  2a02:750::1:1  53.730 ms
14  2a02:750:0:501::102  55.805 ms
traceroute to 2001:888:12b4::a604:3001 (2001:888:12b4::a604:3001), 30 hops max, 80 byte packets
 1  2001:630:301:1100::2  0.730 ms
 2  2001:630:301:7005::1  1.071 ms
 3  2001:630:302:c01::feed:1  1.078 ms
 4  2001:630:302:705::feed:1  5.965 ms
 5  2001:630:0:8045::601  3.151 ms
 6  2001:630:0:10::3e  6.342 ms
 7  2001:630:0:10::9a  6.570 ms
 8  2001:668:0:3::4000:401  6.788 ms
 9  2001:668:0:2::1:861  6.563 ms
10  2001:668:0:2::1:1c31  12.222 ms
11  2001:668:0:2::1:19f2  12.356 ms
12  2001:668:0:3::6000:102  17.406 ms
13  2001:888:0:1152::1  17.218 ms
14  2001:888:0:3::42  18.772 ms
15  2001:888:12b4::a604:3001  29.074 ms
traceroute to 2001:1ba0:2a0:5965:0:30:32:1 (2001:1ba0:2a0:5965:0:30:32:1), 30 hops max, 80 byte packets
 1  2001:630:301:1100::2  0.677 ms
 2  2001:630:301:7005::1  0.811 ms
 3  2001:630:302:c01::feed:1  0.825 ms
 4  2001:630:302:705::feed:1  1.464 ms
 5  2001:630:0:8045::601  2.984 ms
 6  2001:630:0:10::3e  6.222 ms
 7  2001:630:0:10::9a  6.604 ms
 8  2001:630:0:10::152  6.615 ms
 9  2001:7f8:4::7218:1  34.889 ms
10  2001:4de8:d1a1:1111:4::1  34.891 ms
11  2001:4de8:d1a1:1111:1f::2  34.848 ms
12  2001:4de8:d1a1:1111:11::2  40.155 ms
13  2001:1ba0:babe::1:2  40.309 ms
14  2001:1ba0:2a0:5965:0:30:32:1  40.154 ms

I need to sort the IP address in front of "traceroute to" and the last one on route trace.
Please i want them to look like;

2001:1ba0:2a0:5965:0:30:24:1 destination is 2001:1ba0:2a0:5965:0:30:24:1
2001:8a8:21:5:216:3eff:fec1:423 destination is 2001:8a8:21:5:216:3eff:fec1:423
.........and like that for the rest

Bear in mind please that the list is so long. thanks

Are those two addresses always the same? If so then this should do:

awk '/trace/{print $3" destination is "$3}' file

Something like this?

awk -F"[ ()]" '/traceroute/ {print $3 " destination is " $5}' file

Thanks guys, I just ran the script and I noticed it wasn't printing the last line(IP addresss) of each traceroute correct, i will inbox you a copy of my whole data so you can run it and see what I mean.

awk -vRS="tr" 'NR>1{print $3" destination is "$(NF-2)}' file
1 Like

Sorry, I cant see any option to attach a file in the private message thingy,the list is so long and contains some like this;

traceroute to 2a02:c50:: (2a02:c50::), 30 hops max, 80 byte packets
 1  2001:630:301:1100::2  0.518 ms
 2  2001:630:301:7005::1  0.870 ms
 3  2001:630:302:c01::feed:1  0.877 ms
 4  2001:630:302:905::feed:1  1.974 ms
 5  2001:630:0:8040::601  5.049 ms
 6  2001:630:0:10::9a  5.271 ms
 7  2001:668:0:3::4000:401  5.289 ms
 8  2001:668:0:2::1:861  5.264 ms
 9  2001:668:0:2::1:14b2  5.426 ms
10  2001:668:0:2::1:312  5.401 ms
11  2001:668:0:2::1:1672  16.176 ms
12  2001:7f8::15a3:0:2  16.659 ms
13  2001:608:0:e09::202  17.433 ms
14  2001:7f8:0:2:0:1a27:0:1  123.375 ms
15  *
16  *
17  *
18  *
19  *
20  *
21  *
22  *
23  *
24  *
25  *
26  *
27  *
28  *
29  *
30  *
traceroute to 2a02:ae8:101:1fe::12 (2a02:ae8:101:1fe::12), 30 hops max, 80 byte packets
 1  2001:630:301:1100::2  0.462 ms
 2  2001:630:301:7005::1  0.818 ms
 3  2001:630:302:c01::feed:1  0.977 ms
 4  2001:630:302:905::feed:1  2.289 ms
 5  2001:630:0:8040::601  4.996 ms
 6  2001:630:0:10::9a  5.252 ms
 7  2001:668:0:3::4000:3f1  5.592 ms
 8  2001:668:0:2::1:861  5.392 ms
 9  2001:668:0:2::1:1c31  11.119 ms
10  2001:7f8:1::a502:5466:1  46.451 ms
11  2001:be8:f000:f001::2  46.459 ms
12  2001:be8:0:8::2  49.634 ms
13  2001:be8:23ff:ff01::2  51.144 ms
14  2001:1630:0:75::2  51.865 ms
15  2a02:ae8:0:74::2  52.061 ms
16  2a02:ae8:101::2  51.865 ms
17  *
18  *
19  *
20  *
21  *
22  *
23  *
24  *
25  *
26  *
27  *
28  *
29  *
30  *

And I observed after running the script, that it is still print traceroute to IP and destination (last IP on the traceroute) as the same instead of different ones. i.e

2a02:c50:: destination is  2001:7f8:0:2:0:1a27:0:1

But instead i got;

2a02:c50:: destination is 2a02:c50:: 

which is wrong.
If you dont mind send me your email so I can forward the whole data to you for better understanding of what I meant, Thanks

---------- Post updated at 08:00 PM ---------- Previous update was at 07:53 PM ----------

thanks bartus11, its perfect now and thanks to you too Franklin52 for responding.You all are highly appreciated.

You should post real data in the first post... It would save us as well as yourself a lot of time:

awk '!/\*/' file | awk -vRS="tr" 'NR>1{print $3" destination is "$(NF-2)}'