Parsing a file with AWK


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Parsing a file with AWK
# 1  
Old 04-20-2011
Parsing a file with AWK

Input
Code:
 
Group: 
  Erecords: 
    Copy: 
      ADC R2: 
        Replication volumes: 
          Replication set: RSet 1
          Replication size: 50.00GB
          SAN Info: 
            50.00GB  DGC  VRAID  CX4-960  LUN 1040 (1040)  60,06,01,60,32,bb,21,00,84,a0,08,b1,da,ec,df,11 0x96e839c701a4584f  
            RPA Port      WWN        Ctrl   Serial          LUN               
            -------------------------------------------------------
             1   0  500601603b203c15 SP-A   APM00104200916   32                
             1   0  500601693b203c15 SP-B   APM00104200916   32                
             1   3  500601613b203c15 SP-A   APM00104200916   32                
             2   3  500601683b203c15 SP-B   APM00104200916   32                
 
 
          Replication set: RSet 10
          Replication size: 900.00GB
          SAN Info: 
            900.00GB  DGC  VRAID  CX4-960  LUN 1153 (1153)  60,06,01,60,32,bb,21,00,6a,d7,a9,29,f8,65,e0,11 0x447102a705ca7505  
            RPA Port      WWN        Ctrl   Serial          LUN               
            -------------------------------------------------------
             1   0  500601603b203c15 SP-A   APM00104200916   46                
             1   0  500601693b203c15 SP-B   APM00104200916   46                
             1   3  500601613b203c15 SP-A   APM00104200916   46                
             2   3  500601683b203c15 SP-B   APM00104200916   46                
 
 
          Replication set: RSet 11
          Replication size: 50.00GB
          SAN Info: 
            50.00GB  DGC  VRAID  CX4-960  LUN 1114 (1114)  60,06,01,60,32,bb,21,00,36,e8,cb,58,44,ec,df,11 0xe448ff38046c7c02  
            RPA Port      WWN        Ctrl   Serial          LUN               
            -------------------------------------------------------
             1   0  500601603b203c15 SP-A   APM00104200916   54                
             1   0  500601693b203c15 SP-B   APM00104200916   54                
             1   3  500601613b203c15 SP-A   APM00104200916   54                
             2   3  500601683b203c15 SP-B   APM00104200916   54                
 
 
            Journal volumes: 
            SAN Info: 
            20.00GB  DGC  VRAID  CX4-960  LUN 3008 (3008)  60,06,01,60,32,bb,21,00,2c,cb,8d,0d,a0,5b,e0,11 0xfaadda2c7f0b6b38  
            RPA Port      WWN        Ctrl   Serial          LUN               
            -------------------------------------------------------
             1   0  500601603b203c15 SP-A   APM00104200916   14                
             1   0  500601693b203c15 SP-B   APM00104200916   14                
             1   3  500601613b203c15 SP-A   APM00104200916   14                
             2   3  500601683b203c15 SP-B   APM00104200916   14      
CNJ R1:
        Replication volumes:
          Replication set: RSet 1
          Replication size: 50.00GB
          SAN Info:
            50.00GB  DGC  VRAID  CX4-960 LUN 19 (19)  60,06,01,60,f8,7b,21,00,4e,c0,62,26,45,ec,df,11 0x384ade8bcd121455
            RPA Port      WWN        Ctrl   Serial          LUN
            -------------------------------------------------------
             1   0  500601603b206fe3 SP-A   APM00104000792   6
             1   0  500601693b206fe3 SP-B   APM00104000792   6
             1   2  500601613b206fe3 SP-A   APM00104000792   6
             2   2  500601683b206fe3 SP-B   APM00104000792   6
 
 
          Replication set: RSet 10
          Replication size: 900.00GB
          SAN Info:
            900.00GB  DGC  VRAID  CX4-960  LUN 153 (153)  60,06,01,60,42,84,1e,00,d2,de,e2,71,69,38,e0,11 0x229fa2716b3bd65c
            RPA Port      WWN        Ctrl   Serial          LUN
            -------------------------------------------------------
             1   0  500601603b206fe3 SP-A   APM00104000792   37
             1   0  500601693b206fe3 SP-B   APM00104000792   37
             1   2  500601613b206fe3 SP-A   APM00104000792   37
             2   2  500601683b206fe3 SP-B   APM00104000792   37
 
 
          Replication set: RSet 11
          Replication size: 50.00GB
          SAN Info:
            50.00GB  DGC  VRAID  CX4-960  LUN 14 (14)  60,06,01,60,f8,7b,21,00,6e,7c,f4,f5,43,ec,df,11 0x2e110e4a707e364d
            RPA Port      WWN        Ctrl   Serial          LUN
            -------------------------------------------------------
             1   0  500601603b206fe3 SP-A   APM00104000792   39
             1   0  500601693b206fe3 SP-B   APM00104000792   39
             1   2  500601613b206fe3 SP-A   APM00104000792   39
             2   2  500601683b206fe3 SP-B   APM00104000792   39
 
 
          Journal volumes:
          SAN Info:
            20.00GB  DGC  VRAID  CX4-960  LUN 3009 (3009)  60,06,01,60,42,84,1e,00,c8,b8,e7,2c,6f,5c,e0,11 0x4271daf012ded464
            RPA Port      WWN        Ctrl   Serial          LUN
            -------------------------------------------------------
             1   0  500601603b206fe3 SP-A   APM00104000792   21
             1   0  500601693b206fe3 SP-B   APM00104000792   21
             1   2  500601613b206fe3 SP-A   APM00104000792   21
             2   2  500601683b206fe3 SP-B   APM00104000792   21
 
 
   RMAN:
    Copy:
      ADC R2:
        Replication volumes:
          Replication set: RSet 1
          Replication size: 0.97TB
          SAN Info:
            0.97TB  DGC  RAID 5  CX4-960  M 1010 (1010)  60,06,01,60,f9,f6,22,00,1c,e5,9f,b8,90,f4,dd,11 0x6756f6a64c132e15
            RPA Port      WWN        Ctrl   Serial          LUN
            -------------------------------------------------------
             1   0  500601613b20135c SP-A   APM00084900375   3
             1   0  500601683b20135c SP-B   APM00084900375   3
             1   3  500601603b20135c SP-A   APM00084900375   3
             2   3  500601693b20135c SP-B   APM00084900375   3
 
         Journal volumes:
          SAN Info:
            20.00GB  DGC  VRAID  CX4-960  LUN 3002 (3002)  60,06,01,60,01,7b,25,00,16,d0,a1,37,e3,56,e0,11 0xfd88b419c2c2655
            RPA Port      WWN        Ctrl   Serial          LUN
            -------------------------------------------------------
             1   0  500601603b203c15 SP-A   APM00104200916   8
             1   0  500601693b203c15 SP-B   APM00104200916   8
             1   3  500601613b203c15 SP-A   APM00104200916   8
             2   3  500601683b203c15 SP-B   APM00104200916   8
 
        CNJ R1:
        Replication volumes:
          Replication set: RSet 1
          Replication size: 0.97TB
          SAN Info:
            0.97TB  DGC  RAID 5  CX4-960  M 10 (10)  60,06,01,60,0d,de,22,00,da,46,be,8c,83,f4,dd,11 0xdfe09df54ca00bcb
            RPA Port      WWN        Ctrl   Serial          LUN
            -------------------------------------------------------
             1   0  500601603b20148b SP-A   FNM00085200014   5
             1   0  500601693b20148b SP-B   FNM00085200014   5
             1   2  500601613b20148b SP-A   FNM00085200014   5
             2   2  500601683b20148b SP-B   FNM00085200014   5
 
          Journal volumes:
          SAN Info:
            20.00GB  DGC  VRAID  CX4-960  LUN 3011 (3011)  60,06,01,60,42,84,1e,00,cc,b8,e7,2c,6f,5c,e0,11 0xe62c280adfe83332
            RPA Port      WWN        Ctrl   Serial          LUN
            -------------------------------------------------------
             1   0  500601603b206fe3 SP-A   APM00104000792   23
             1   0  500601693b206fe3 SP-B   APM00104000792   23
             1   2  500601613b206fe3 SP-A   APM00104000792   23
             2   2  500601683b206fe3 SP-B   APM00104000792   23


Ouput needed


Code:
 
APM00104000792,Erecords,CNJ R1,RSet1,LUN 19,50.00GB,APM00104200916,ADC R2,LUN 1040 
APM00104000792,Erecords,CNJ R1,RSet10,LUN 153,50.00GB,APM00104200916,ADC R2,LUN 1153 
APM00104000792,Erecords,CNJ R1,RSet11,LUN 14,50.00GB,APM00104200916,ADC R2,LUN 1114
FNM00085200014,RMAN,CNJ R1,RSet1,M 10,0.97TB,APM00084900375,ADC R2,M 1010
 
APM00104000792,Erecords,Journal volumes,LUN 3009,20.00GB
APM00104200916,Erecords,Journal volumes,LUN 3008,20.00GB
APM00104200916,RMAN,Journal volumes,LUN 3002,20.00GB
APM00104000792,RMAN,Journal volumes,LUN 3011,20.00GB


Records i want to grab are in RED .Pls note records like RMAN,Erecords,ADC R2,CNJ R1 may not be same and can change

thx

---------- Post updated 04-20-11 at 10:49 AM ---------- Previous update was 04-19-11 at 10:54 AM ----------

Tried this ..... not getting me the desired result

Code:
 
nawk  'BEGIN{ RS="\n"}
/Group:/ { getline ; grp=$NF ;getline ;getline; ;dee=$0 }
/Replication set:/ { SOU=$3" "$4 }
/Replication size:/ { TGT=$3 }
/DGC/ { STS=$5" "$6 }
/SP-A/ { CLA=$5
 printf "%s\n",grp","dee","SOU","TGT","STS
                FS=" "
}'   file

Code:
 
Erecords:,      ADC R2: ,APM00104200916,RSet 1,50.00GB,LUN 1040
Erecords:,      ADC R2: ,APM00104200916,RSet 1,50.00GB,LUN 1040
Erecords:,      ADC R2: ,APM00104200916,RSet 10,900.00GB,LUN 1153
Erecords:,      ADC R2: ,APM00104200916,RSet 10,900.00GB,LUN 1153
Erecords:,      ADC R2: ,APM00104200916,RSet 11,50.00GB,LUN 1114
Erecords:,      ADC R2: ,APM00104200916,RSet 11,50.00GB,LUN 1114
Erecords:,      ADC R2: ,APM00104200916,RSet 11,50.00GB,LUN 3008
Erecords:,      ADC R2: ,APM00104200916,RSet 11,50.00GB,LUN 3008
Erecords:,      ADC R2: ,APM00104000792,RSet 1,50.00GB,LUN 19
Erecords:,      ADC R2: ,APM00104000792,RSet 1,50.00GB,LUN 19
Erecords:,      ADC R2: ,APM00104000792,RSet 10,900.00GB,LUN 153
Erecords:,      ADC R2: ,APM00104000792,RSet 10,900.00GB,LUN 153
Erecords:,      ADC R2: ,APM00104000792,RSet 11,50.00GB,LUN 14
Erecords:,      ADC R2: ,APM00104000792,RSet 11,50.00GB,LUN 14
Erecords:,      ADC R2: ,APM00104000792,RSet 11,50.00GB,LUN 3009
Erecords:,      ADC R2: ,APM00104000792,RSet 11,50.00GB,LUN 3009


Last edited by greycells; 04-20-2011 at 04:12 PM..
# 2  
Old 04-20-2011
I'm having trouble seeing the pattern. why do you care about CNJ R1: but not Group:, why do you care about RSet 1 but not RSet 10?
# 3  
Old 04-20-2011
Highlighted all the required fields now ... Group is only at the start of file ...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing a file name with awk

I have a command to print out the top 5 most cpu intensive commands: ps aux --sort=-%cpu --no-headers I would like to make a printout containing only the parsed file name. So, I want to turn this: $ ps aux --sort=-%cpu --no-headers user 24883 4.3 1.7 2010436 131440 ? Sl ... (2 Replies)
Discussion started by: bedtime
2 Replies

2. Shell Programming and Scripting

awk parsing file

Looking to parse a file to remove the duplicates and get only few fields and uniq rows. input.tx Loc (TC) ID : ssfad_fs Serial : PIC002340098 ... (8 Replies)
Discussion started by: shunya
8 Replies

3. Shell Programming and Scripting

AWK? parsing /etc/passwd file.

Hello guys, please help me to make simple script for parsing passwd file. I have many passwd files from our servers, named server1.pass, server2.pass etc.. so for server in `ls *.pass` i need to print these rows: server1;root:!:0:0::/root:/usr/bin/ksh... (7 Replies)
Discussion started by: rubico
7 Replies

4. Shell Programming and Scripting

Help in file parsing with awk

Hi, I have a data set as shown below: 09e757fd,22727,2012-03-01,text1,text2,to 3fd0cae7,310,2012-03-01,text3,text4,to 3fd0cae7,310,2012-03-01,text3,text5,to 3fd0cae7,311,2012-03-01,text7,text10,cc 3fd0cae7,311,2012-03-01,text7,text11,to 3fd0cae7,312,2012-03-01,text8,text15,to... (3 Replies)
Discussion started by: shekhar2010us
3 Replies

5. UNIX for Advanced & Expert Users

Parsing through a file with awk/sed

I don't necessary have a problem, as I have a solution. It is just that there may be a better solution. GOAL: Part one: Parse data from a file using the "\" as a delimiter and extracting only the last delimiter. Part two: Parse same file and extract everything but the last delimited item. ... (8 Replies)
Discussion started by: OrangeYaGlad
8 Replies

6. Shell Programming and Scripting

awk/sed for parsing file

Hi All, I have a log file like this E Mon Oct 06 00:17:08 2008 xxx2 cm:10614 fm_pi2_svc_iptv_purchase.c:149 1:pin_deferred_act:10601:11:169:1223245028:16 pi2_op_svc_iptv_purchase error <location=PIN_ERRLOC_FM:5 class=PIN_ERRCLASS_SYSTEM_DETERMINATE:1... (10 Replies)
Discussion started by: subin_bala
10 Replies

7. Shell Programming and Scripting

Parsing a file (sed/awk?)

Hello people, newbie question. I'm trying to parse these type of file 1 "CAR " " C1 " " " 6 0 C1 2 "CAR " " O1A" " " 8 0 O1A 3 "CAR " " O1B" " " 8 -1 O1B 4 "CAR " " C2 " " " 6 0 C2 5 "CAR " " C3 " " " 6 ... (10 Replies)
Discussion started by: aristegui
10 Replies

8. Shell Programming and Scripting

awk and file parsing

Hi, I have a input file like this TH2TH2867Y NOW33332106Yo You Baby TH2TH3867Y NOW33332106No Way Out TH2TH9867Y NOW33332106Can't find it TJ2TJ2872N WOW33332017sure thing alas TJ2TJ3872N WOW33332017the sky rocks TJ2TJ4872N WOW33332017nothing else matters ... (4 Replies)
Discussion started by: devtakh
4 Replies

9. Shell Programming and Scripting

AWK and Magic with file parsing

Hi, I have a input file like this TH2TH2867Y NOW33332106Yo You Baby TH2TH3867Y NOW33332106No Way Out TH2TH9867Y NOW33332106Can't find it TJ2TJ2872N WOW33332017sure thing alas TJ2TJ3872N WOW33332017the sky rocks TJ2TJ4872N WOW33332017nothing else matters TJ2TJ5872N WOW33332017you know... (1 Reply)
Discussion started by: devtakh
1 Replies

10. Shell Programming and Scripting

parsing file through awk

hi, how can i achieve this in awk CON Controllers Department R abcuser usernamedesc1 R defuser usernamedesc2 R ... (13 Replies)
Discussion started by: bbeugie
13 Replies
Login or Register to Ask a Question