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

Packets and Perl

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Hi
I have a text file that looks like this

Link encap:Ethernet HWaddr 00:00:B4:44:E2:4B
inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::200:b4ff:fe44:e24b/10 Scope:Link
inet6 addr: fe80::b444:e24b/10 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:26336217 errors:0 dropped:166 overruns:0 frame:2554
TX packets:26793895 errors:0 dropped:0 overruns:0 carrier:0
collisions:70878 txqueuelen:100
RX bytes:981223126 (935.7 Mb) TX bytes:4191645335 (3997.4 Mb)
Interrupt:10 Base address:0x260

What is the diffrent between RX bytes and TX bytes ??

The next question is how to grep 2 values in the file

Line 9 looks like this

RX bytes:981223126 (935.7 Mb) TX bytes:4191645335 (3997.4 Mb)

How can I grep the RX bytes value 981223126, (yes it will be diffrent each time) and I also want to grep the TX bytes value 4191645335

It's just the long value I want to grep, not the (xxxx) value.

Thanks
//Fredrik
 
Code:
my $str = 'RX bytes:981223126 (935.7 Mb)  TX bytes:4191645335 (3997.4 Mb)';
$str =~ /RX bytes:(\d+).*TX bytes:(\d+)/;
printf("RX: %u, TX: %u\n", $1, $2);

Of course you need only the middle line - the rest is for demonstration purposes only ;-) Jean Spector
QA Engineer @ mSAFE Ltd.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top