My data looks like the following:
I am passing it to awk and I am trying to get the following result:
I have gotten this so far, but I don't know if I'm going in the right direction:
awk 'BEGIN{printf "%-32s %-32s %-12s\n", "name","wan","status"}/^name/{n=$2}/^WWPN/{w[$2]=w[$2]}END{for(i in w)printf "%-32s %-32s %-10s\n", n,i}'
any help appreciated. The input data is just one dataset, I will be piping in multiple datasets/inputs into awk to create the table. So there will be different Servers with different WWNs. Awk script needs to be able to handle variable number of WWNs.
Code:
id 34
name SERVERABC
port_count 2
type generic
mask 1111111111111111111111111111111111111111111111111111111111111111
iogrp_count 4
status online
site_id
site_name
host_cluster_id
host_cluster_name
WWPN 5001438002A3005A
node_logged_in_count 8
state active
WWPN 5001438002A30058
node_logged_in_count 8
state degraded
WWPN 5001438002A3005D
node_logged_in_count 8
state active
WWPN 5001438002A3005E
node_logged_in_count 8
state offline
I am passing it to awk and I am trying to get the following result:
Code:
Name WWN State
SERVERABC 5001438002A3005A active
SERVERABC 5001438002A30058 degraded
SERVERABC 5001438002A3005D active
SERVERABC 5001438002A3005E offline
I have gotten this so far, but I don't know if I'm going in the right direction:
awk 'BEGIN{printf "%-32s %-32s %-12s\n", "name","wan","status"}/^name/{n=$2}/^WWPN/{w[$2]=w[$2]}END{for(i in w)printf "%-32s %-32s %-10s\n", n,i}'
any help appreciated. The input data is just one dataset, I will be piping in multiple datasets/inputs into awk to create the table. So there will be different Servers with different WWNs. Awk script needs to be able to handle variable number of WWNs.