Sponsored Content
Full Discussion: Weird Interpretation by Awk
Top Forums Shell Programming and Scripting Weird Interpretation by Awk Post 302247010 by Legend986 on Tuesday 14th of October 2008 06:58:34 PM
Old 10-14-2008
Yes sure... I was trying to process a BGP Dump file. I am not sure if I can get the exact structure here though.

Code:
*  3.0.0.0          193.0.0.56                             0 3333 3356 701 703 80 i
*                   217.75.96.60             0             0 16150 3549 701 703 80 i
*                   64.125.0.137           124             0 6461 701 703 80 i
*                   209.10.12.156            0             0 4513 701 701 703 80 i
*                   134.55.200.1                           0 293 701 703 80 i
*                   194.85.4.55                            0 3277 3216 3549 701 703 80 i
*                   66.59.190.221                          0 6539 2914 701 703 80 i
*                   209.10.12.160                          0 4513 701 701 703 80 i
*                   164.128.32.11                          0 3303 701 703 80 i
*                   207.46.32.34                           0 8075 701 703 80 i
*                   196.7.106.245            0             0 2905 702 703 80 i
*                   154.11.11.113            0             0 852 1239 701 703 80 i
*                   89.149.178.10           10             0 3257 701 703 80 i
*                   154.11.98.225            0             0 852 1239 701 703 80 i
*>                  157.130.10.233                         0 701 703 80 i
*                   129.250.0.171            0             0 2914 701 703 80 i
*                   129.250.0.11             6             0 2914 701 703 80 i
*                   66.185.128.48          504             0 1668 701 703 80 i
*                   4.68.1.166               0             0 3356 701 703 80 i
*                   207.172.6.20             5             0 6079 3356 701 703 80 i
*                   213.140.32.146                         0 12956 3356 701 703 80 i
*                   65.106.7.139             3             0 2828 701 703 80 i
*                   207.246.129.13                         0 11608 2914 701 703 80 i
*                   203.62.252.186                         0 1221 4637 703 80 i
*                   193.251.245.6                          0 5511 701 703 80 i
*                   195.219.96.239                         0 6453 701 703 80 i
*                   207.45.223.244                         0 6453 701 703 80 i
*                   12.0.1.63                              0 7018 701 703 80 i
*                   144.228.241.81  4294967294             0 1239 701 703 80 i
*                   208.51.134.254           0             0 3549 701 703 80 i
*                   206.24.210.100                         0 3561 701 703 80 i
*                   202.232.0.2                            0 2497 701 703 80 i
*                   134.222.85.45                          0 286 3549 701 703 80 i
*                   207.172.6.162            6             0 6079 3356 701 703 80 i
*                   209.10.12.125         4122             0 4513 701 701 703 80 i
*                   216.218.252.164                        0 6939 3549 701 703 80 i
*                   203.181.248.168                        0 7660 2516 209 701 703 80 i
*                   202.249.2.86                           0 7500 2497 701 703 80 i
*                   64.71.255.61                           0 812 6461 701 703 80 i
*  4.0.0.0/9        193.0.0.56                             0 3333 3356 i
*                   217.75.96.60             0             0 16150 1239 3356 i
*                   64.125.0.137           124             0 6461 3356 i
*                   209.10.12.156            0             0 4513 3356 3356 3356 i
*                   134.55.200.1                           0 293 3356 i
*                   194.85.4.55                            0 3277 3267 25462 3356 i
*                   66.59.190.221                          0 6539 2914 3356 i
*                   209.10.12.160                          0 4513 701 701 3356 i

As you can observe, I want only the IP Addresses in the second column. What I actually want to do is to replicate the same IP address until the next IP address is encountered. So the expected output is something like this:

Code:
3.0.0.0    3333 3356 701 703 80
3.0.0.0    16150 3549 701 703 80
... so on... until the next IP is encountered
4.0.0.0/9    3333 3356
4.0.0.0/9    3561 701 703 80

Hope I was able to convey my requirement properly. Thanks a lot for the advices though.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

SAR -b interpretation

I have used SAR -b to get some Unix cache / buffer metrics and the results are confusing me a bit. The pread/s & pwrit/s are showing 0. However the lread/s and lwrit/s are showing figures. I note also that the bread/s and bwrit/s are showing figures. I believe that pread/s and pwrit/s is not... (3 Replies)
Discussion started by: jimthompson
3 Replies

2. AIX

interpretation of sar

hello with a sar i have this result: System configuration: lcpu=48 ent=4.00 14:06:37 %usr %sys %wio %idle physc %entc 14:06:39 26 9 3 62 1.63 40.7 14:06:41 26 9 3 63 1.58 39.4 14:06:43 ... (0 Replies)
Discussion started by: pascalbout
0 Replies

3. UNIX for Advanced & Expert Users

Weird scenario with Awk

Guys, this one is rather odd. I've got an array of numbers, and I'm trying to select only the records with the string "Random" in the 4th column. I'm using awk in this format: awk '{ if (( $6 -eq Random )) print $0 }' For some odd reason, this is simply giving me the list of all the entries... (4 Replies)
Discussion started by: Khoomfire
4 Replies

4. UNIX for Advanced & Expert Users

Weird Awk issue

Hi All, a bit of a weird one here. I'm trying to pass a variable into an awk command, and I keep getting an error. I have the line nawk -F"," -v red=$random_variable '{print $red}' $w_dir/$file_name > $w_dir/${column_name} that keeps failing with the error nawk: can't open file {print... (17 Replies)
Discussion started by: Khoomfire
17 Replies

5. Shell Programming and Scripting

awk, sed, grep...weird style

my desired output is like this: so the thing is, I only need to show every of this part out but the frequency of that data is not fixed, so sometimes it may have 4 lines, or 6 lines or whatever in that file. However, the last line will always have empty space/line below it. (13 Replies)
Discussion started by: finalight
13 Replies

6. Shell Programming and Scripting

awk print behavior weird

Hi Experts I am facing a weird issue while using print statement in awk. I have a text file with 3 fields shown below: # cat f1 234,abc,1000 235,efg,2000 236,jih,3000 # When I print the third column alone, I dont face any issue as shown below: # awk '{print $3 }' FS=, f1 1000 2000... (5 Replies)
Discussion started by: guruprasadpr
5 Replies

7. Shell Programming and Scripting

awk weird problem.

awk 'BEGIN{print 1.2.3.4}' 1.20.30.4 Can anyone explain why has extra "0" in the IP address? (3 Replies)
Discussion started by: newoz
3 Replies

8. Shell Programming and Scripting

Interpretation of awk code in linux

HI I have a following code: CM_PROJHOME_DIR=`echo ${SCRNAME} | awk '{FS="/"; p=NF-5; for (i=1; i<= p ; i++) t=t$i"/"; print t}'` where SCRNAME=`whence $0 | sed -e 's/\.\///g'` I need to modify the code to work in linux and also the interpretation like what is the code exactly doing.... (4 Replies)
Discussion started by: vee_789
4 Replies

9. Shell Programming and Scripting

Weird awk problem

Hi, I have a simple awk script: BEGIN{} { $a=$2-$1; print $a } END{if(NR==0){ print "0" } } to which I provide the following input 2.9 14 22.2 27 (4 Replies)
Discussion started by: jamie_123
4 Replies

10. Shell Programming and Scripting

awk weird error

Here is the awk code i wrote : if ; then gawk -v field_position="$field_position" -v field_length="$field_length" -v header="$header" -v trailer="$trailer" -v lr="$lr" '{ if(NR==1&&header=="1") { next } if(NR==lr&&trailer=="1") { next }... (1 Reply)
Discussion started by: ysvsr1
1 Replies
All times are GMT -4. The time now is 02:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy