Computing.Net > Forums > Programming > AWK assistance

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

AWK assistance

Reply to Message Icon

Name: user57
Date: September 2, 2009 at 07:24:23 Pacific
OS: AIX 5.3
CPU/Ram: 4 CPU / 32 GB RAM
Subcategory: General
Comment:

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: ent8

ETHERNET STATISTICS (ent8) :
Priority: 2

ETHERNET STATISTICS (ent0) :
Priority: 1 Active: True
ETHERNET STATISTICS (ent1) :

Virtual Adapter: ent3
LAN State: Operational

ETHERNET STATISTICS (ent3) :
LAN State: Operational
Control Adapter: ent2

ETHERNET STATISTICS (ent2) :
Virtual I/O Ethernet Adapter (l-lan) Specific Statistics:


Desired output:
State;PRIMARY
Mode;Auto
Priority;1

adpter=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}'




Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Findstr suggestions changing the listbox high...



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: AWK assistance

Awk Arrays www.computing.net/answers/programming/awk-arrays/14279.html

AWK text grab www.computing.net/answers/programming/awk-text-grab/16354.html

AWK help www.computing.net/answers/programming/awk-help/19851.html