Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I wonder if someone can assist. I'm attempting to generate a 3 line output from a rather lengthy file (see input extract).
I'm interested in the State, High Availability Mode and Priority values of adapter ent9 only. This adapter (ent9) has been parsed via the -v option.
I'm essentially interested in a mere 3 lines associated with ent9 stanza which may occur anywhere in the file. My key problem is I keep pulling in 'rogue' lines I have no interest in.
How do I switch off processing on encountering the final value of interest to me - "Priority: 1"
Thanks,
Input file:
ETHERNET STATISTICS (ent9) :
Statistics for adapters in the Shared Ethernet Adapter ent9
State: PRIMARY
High Availability Mode: Auto
Priority: 1
Real Adapter: ent8ETHERNET STATISTICS (ent8) :
Priority: 2ETHERNET STATISTICS (ent0) :
Priority: 1 Active: True
ETHERNET STATISTICS (ent1) :Virtual Adapter: ent3
LAN State: OperationalETHERNET STATISTICS (ent3) :
LAN State: Operational
Control Adapter: ent2ETHERNET STATISTICS (ent2) :
Virtual I/O Ethernet Adapter (l-lan) Specific Statistics:
Desired output:
State;PRIMARY
Mode;Auto
Priority;1adpter=ent9
nawk -v adpter=${adpter} 'BEGIN {FS=":"}
$0 ~/^Statistics for adapters in the Shared Ethernet Adapter/ && $0 ~adpter { next }
$0 ~/State/ { STATE=$2; printf("%s;%s\n", "State",substr(STATE,2)) }
$0 ~/Mode/ { print ... etc}
$0 ~/Priority/ {print ...etc}'

![]() |
Findstr suggestions
|
changing the listbox high...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |