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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to output to a single line 1

Status
Not open for further replies.

bpk89

Technical User
Feb 14, 2002
6
AU
The 'x25stat' program I use produces an output similar to below.

$ x25stat

GLOBAL STATISTICS FOR X25
-------------------------------------
Packet type TX RX
-------------------------------------
Packets(total) 2314667 2450836
Bytes(total) 31835647 36789526
$

From the cron I want to call a script that runs 'x25stat' and outputs Packets TX, Packets Rx, Bytes TX and Bytes RX into a single pipe delimited line. Something like:

2314667 | 2450836 | 31835647 | 36789526

Can use sh or ksh. TIA
 
This ought to work for you.

Code:
x25stat | awk 'BEGIN { FS = " " } /^ *Packets/ { ptx = $2; prx = $3 } /^ *Bytes/ { btx = $2; brx = $3 } END { print ptx " | " prx " | " btx " | " brx }'

-
 
Thanks azimuth0! Your awk script produces the output I require.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top