1841262 Members
3106 Online
110179 Solutions
New Discussion

netstat -i parse output

 
SOLVED
Go to solution
Rick Garland
Honored Contributor

netstat -i parse output

All hi:

I am looking for the network traffic going in/out of HPUX systems. When executing the netstat -i command the number if Ipkts & Opkts is on another line. I'm at a loss on how to script this output so I can get the values that match with a particular interface. Example;
lan900 1500 (IP) (HOST)
(some number) (some number)
As seen, the numbers are on another line.
2 REPLIES 2
James R. Ferguson
Acclaimed Contributor
Solution

Re: netstat -i parse output

Hi Rick:

# netstat -i | awk '{if (NF!=9) {LINE=$0;getline;print LINE,$0} else {print}}'

Regards!

...JRF...
Rick Garland
Honored Contributor

Re: netstat -i parse output

Many thanks JRF

A little massaging gets what I want!