LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-15-2001, 06:25 PM   #1
FredrikN
Member
 
Registered: Nov 2001
Location: Sweden
Distribution: GNU/Linux since -97
Posts: 149

Rep: Reputation: 15
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
 
Old 12-16-2001, 04:21 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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
 
Old 12-16-2001, 11:55 AM   #3
FredrikN
Member
 
Registered: Nov 2001
Location: Sweden
Distribution: GNU/Linux since -97
Posts: 149

Original Poster
Rep: Reputation: 15
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to assign result of grep to var in PERL amytys Programming 1 09-23-2004 06:25 PM
howto grep in perl bishal Programming 7 07-19-2004 01:32 AM
grep issue of escaping backticks in perl rajatgarg Programming 2 05-27-2004 01:27 AM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 11:38 AM
PERL: problem with grep ocularbob Programming 9 05-01-2003 05:36 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration