Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with awk command

Status
Not open for further replies.

mmobra

Technical User
Feb 9, 2011
3
US
Hi all I need help pulling information from a command using AWK or something else?

+-> POOL MEMBER wx1/10.21.4.10:8001 inactive,down
| | session disabled priority 1 ratio 1
| | (cur, max, limit, tot) = (0, 58, 0, 82797)
| | (pkts,bits) in = (1.824M, 2.576G), out = (2.540M, 24.37G)
| | requests (total) = 248862

I would like to have this information and a command to pull it...

wx1 10.21.4.10:8001 inactive,down session disabled

Thanks

Mark
 
Your info starts an the string "POOL MEMBER" so

Code:
/POOL MEMBER/{
 [i]get the info from fields 4 and 5 and put it in a temp var:[/i] l=$4 $5
 [i]but you'll need to substitute "/" for " " in $4:[/i]           sub()
 [i]then you want to read the next line:[/i]                       next 
 [i]the additional info you need is in fields 3 and 4:[/i]         $3 $4
 [i]so print your temp var and those fields:[/i]                   print l $4 $5
}

for more info: read the man page or search for an awk man page on the net...

HTH,

p5wizard
 
/POOL MEMBER/{l=$4 $5 sub() next $3 $4 print l $4 $5}
 
what is the correct syntax? What am I missing?
 
AWK commands need to be terminated by either a newline or a semicolon.
You just concatenated all my hints and were hoping for an automagical program appearance? No deal.
As I suggested before - read the man page - especially look for how to use the sub() function.


HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top