LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Need help with grep or perl (https://www.linuxquestions.org/questions/programming-9/need-help-with-grep-or-perl-10140/)

FredrikN 12-15-2001 06:25 PM

Need help with grep or perl
 
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

unSpawn 12-16-2001 04:21 AM

Rx is bytes receives, Tx is bytes sent.

Im no good at perl, so Ill do a Bash example :-]

cat <file or ifconfig> | grep "RX" | gawk '{print $2, $6}' | sed -e "s/bytes\://g"
this gets both values, $2 or $6 separate to get RX or TX

FredrikN 12-16-2001 11:55 AM

Hi , I have already solve the problem with perl, thanks anyway.

But I have one more question.

It's about this row
RX bytes:981223126 (935.7 Mb) TX bytes:4191645335 (3997.4 Mb)


When the bytes value reaches 5000000000 it starts all over again at 0 bytes and I don't want that.

Is there a way to configure the byte counter or something so it could continue to count bytes ?

//Thanks :)


All times are GMT -5. The time now is 06:48 AM.