Input File
Information about each HBA:
HBA UID: 20:00:00:00:C9:9A:62:88:10:00:00:00:C9:9A:62:88
Server Name: 20:00:00:00:C9:9A:62:88:10:00:00:00:C9:9A:62:88
Server IP Address: UNKNOWN
HBA Model Description:
HBA Vendor Description:
HBA Device Driver Name:
Information about each port of this HBA:
SP Name: SP B
SP Port ID: 0
HBA Devicename:
Trusted: NO
Logged In: YES
Source ID: 332800
Defined: NO
Initiator Type: 3
StorageGroup Name: None
SP Name: SP A
SP Port ID: 1
HBA Devicename:
Trusted: NO
Logged In: YES
Source ID: 332800
Defined: NO
Initiator Type: 3
StorageGroup Name: None
Information about each HBA:
HBA UID: 20:00:00:00:C9:9A:5F:72:10:00:00:00:C9:9A:5F:72
Server Name: joshua
Server IP Address: 172.28.48.25
HBA Model Description:
HBA Vendor Description:
HBA Device Driver Name:
Information about each port of this HBA:
SP Name: SP B
SP Port ID: 1
HBA Devicename: PwrP:c2t500601693B203C15d0s0
Trusted: NO
Logged In: YES
Defined: YES
Initiator Type: 3
StorageGroup Name: joshua
SP Name: SP A
SP Port ID: 0
HBA Devicename: PwrP:c2t500601603B203C15d0s0
Trusted: NO
Logged In: YES
Defined: YES
Initiator Type: 3
StorageGroup Name: joshua
Output needed
Server Name,HBA UID,SP Name:SP Port ID,Logged in ,Defined,StorageGroup Name
20:00:00:00:C9:9A:62:88:10:00:00:00:C9:9A:62:88,20:00:00:00:C9:9A:62:88:10:00:00:00:C9:9A:62:88,SPB:0-SPA:1,YES,NO,None
joshua,20:00:00:00:C9:9A:5F:72:10:00:00:00:C9:9A:5F:72,SPB:1-SPA:0,YES,YES,joshua
Please note that SP Name and SP Port ID appears twice in one record and i want to combine them like this
SP Name:SP PortID-SP Name:SP PortID
Thanks
---------- Post updated at 09:56 AM ---------- Previous update was at 04:12 AM ----------
I tried something like this ... this works for 1st record , but not for 2nd as the record lenght is diff ....
nawk 'BEGIN{ RS="\n"}
/^HBA UID:/ { hbaa=$3}
/Server Name:/ { name=$3}
/SP Name:/ { spa1=$3$4 }
/SP Port ID:/ { port1=$4 ;getline ;getline;getline ;logg=$3;getline;getline ;deff=$2;getline ;getline;getline ;spa2=$3$4;getline;por
t2=$4
printf "%s\n",name","hbaa","spa1":"port1"-"spa2":"port2","logg","deff > "/tmp/c-out"
FS=" "
}' /tmp/input
Output
20:00:00:00:C9:9A:62:88:10:00:00:00:C9:9A:62:88,20:00:00:00:C9:9A:62:88:10:00:00:00:C9:9A:62:88,SPB:0-SPA:1,YES,NO
joshua,20:00:00:00:C9:9A:5F:72:10:00:00:00:C9:9A:5F:72,SPB:1-ID:0:,YES,Type: