Help needed in sorting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help needed in sorting
# 1  
Old 09-13-2010
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;
Code:
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;
Code:
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
# 2  
Old 09-13-2010
Are those two addresses always the same? If so then this should do:
Code:
awk '/trace/{print $3" destination is "$3}' file

# 3  
Old 09-13-2010
Something like this?
Code:
awk -F"[ ()]" '/traceroute/ {print $3 " destination is " $5}' file

# 4  
Old 09-13-2010
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.
# 5  
Old 09-13-2010
Code:
awk -vRS="tr" 'NR>1{print $3" destination is "$(NF-2)}' file

This User Gave Thanks to bartus11 For This Post:
# 6  
Old 09-13-2010
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;
Code:
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
Code:
2a02:c50:: destination is  2001:7f8:0:2:0:1a27:0:1

But instead i got;
Code:
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.
# 7  
Old 09-13-2010
You should post real data in the first post... It would save us as well as yourself a lot of time:
Code:
awk '!/\*/' file | awk -vRS="tr" 'NR>1{print $3" destination is "$(NF-2)}'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help needed in sorting

I have a file which contains following lines: 0114714710147 09013 00025.00D986532147 2814714710147 09013 00045.00D985532147 Now, I need to sort the file with above bold and colured one. Means: first sorting will be done by: 147147 then by 10147 09013 after that by 986532147. The... (2 Replies)
Discussion started by: George1234
2 Replies

2. Red Hat

Sorting

Hi guys, i have a prblm in unix scripting can anyone of you figure it out for me?? The question is i need to store the parent processid and processid in a file and using shell scripting, if i enter the parent processid it should display the processid. one more... (5 Replies)
Discussion started by: rajeshb6
5 Replies

3. UNIX for Dummies Questions & Answers

Help needed sorting syslog columns

Hi all, I need your help in sorting some columns in a syslog report. The command is: for messages in `cat syslog_message_list.txt`; do grep $messages syslog.`date +%d%m%y`.log | \ tr -s " " | cut -d" " -f4,9- | sort| uniq -c >> syslog.`date +%d%m%y`.report; done The output is: 1... (4 Replies)
Discussion started by: wthomas
4 Replies

4. UNIX for Dummies Questions & Answers

Help Needed with Sorting Output

Hi all, I'm using Solaris 10, and need help in sorting the below output from the syslog file in descending rather than ascending order. I would like both the hostname and message columns to be sorted, but right now only the message is sorted and the count column, whose order I would like... (2 Replies)
Discussion started by: wthomas
2 Replies

5. Shell Programming and Scripting

sorting

Hi all, Does anyone can help me the following question? I would like to write an AWK script. In the following input file, each number in "start" is paired with numbers in column "end". No Start End A 22,222,33,22,1233,3232,44 555,333,222,55,1235,3235,66... (7 Replies)
Discussion started by: phoeberunner
7 Replies

6. UNIX for Advanced & Expert Users

HELP on sorting

hi everyone, I am kind of new to this forum. I need help in sorting this data out accordingly, I am actually doing a traceroute application and wants my AS path displayed in front of my address like this; 192.168.1.1 AS28513 AS65534 AS5089 AS5089 .... till the last AS number and if possible... (1 Reply)
Discussion started by: sam127
1 Replies

7. UNIX for Dummies Questions & Answers

HELP on sorting

hi everyone, I am kind of new to this forum. I need help in sorting this data out accordingly, I am actually doing a traceroute application and wants my AS path displayed in front of my address like this; 192.168.1.1 AS28513 AS65534 AS5089 AS5089 .... till the last AS number and if possible... (1 Reply)
Discussion started by: sam127
1 Replies

8. Shell Programming and Scripting

Regarding sorting

I have the following file. Its an output from a du command with certain conditions attached to it. I used du -ah as I need the 1st column to look human readable. sort -nr is not giving me the output I need, nor is sort -dr. Please help out. cat testout 121K ./OMautomation/pvd 14M ... (6 Replies)
Discussion started by: vivek.bharadwaj
6 Replies

9. Shell Programming and Scripting

Need immediate help with sorting!!!

hey, I have a file that looks smthng like this: /*--- abcd_0050 ---*/ asdfjk adsfkja lkjljgafsd /*---abcd_0005 ---*/ lkjkljbfkgj ldfksjgf dfkgfjb /*-- abcd_0055--*/ klhfdghd dflkjgd jfdg I would like it to be sorted so that it looks like this: /*---abcd_0005 ---*/ lkjkljbfkgj (9 Replies)
Discussion started by: sasuke_uchiha
9 Replies

10. Programming

Sorting in C++..

Hi, I need to do a sorting of 2 arrays. One array contains the values of both integer and character and other array can be anything. For example: Array={'1L','2C','NULL','23L','11L','4C','10L','9C'} Array= {'01-02-13-1x','02-11-23-3s','00-12-13-5f','NULL','22k',} If any of these arrays... (6 Replies)
Discussion started by: ronix007
6 Replies
Login or Register to Ask a Question