LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] text processing gotcha

[ILUG] text processing gotcha

Ray Kelly ray at arco.ie
Thu Jun 29 17:13:04 IST 2006


Ladies & gents.

first off apologies for the lack of word wrapping.

I've a box which I want to plot some net stats off, I've been hiveing off the info
by a cron'd "date && ifconfig eth0 >> file.txt" or something similar
after some simple chewing up this has been cleaned/messed to look like the 2
entries below

Tue Jun 20 19:05:01
	RX_packets	2592614097
	TX_packets	805880200
	RX_bytes	703292011	(670.7 MiB)	TX_bytes	81181281	(77.4 MiB)
Tue Jun 20 19:10:01
	RX_packets	2592830080
	TX_packets	805966932
	RX_bytes	989510909	(943.6 MiB)	TX_bytes	150113768	(143.1 MiB)

The basic way that this is now formatted is
Date   {cr}
{tab}  RX  {tab} rx_figure {cr}
{tab}  TX  {tab} tx_figure {cr}
{tab}  RXB {tab} RXB_figure {tab} (blah){tab} TXB {tab} TXB_figure {tab} (blah) {cr}

what I'm trying to do now is to pull all of of this onto one line so
that a carrige return followed by a tab should get replaced by a tab, (I think)
ie get it into the form

date {tab} RX {tab} rx_figure {tab} TX {tab} tx_figure {tab} RXB {tab} RXB_figure {tab} (blah){tab} TXB {tab} TXB_figure {tab} (blah) {cr}
once that's done it can be fired of to whoever so that they can do
whatever they want with excel to it ;)

I've attempted to do this using tr
"cat eth_status.txt | tr '\n' '\t' >> test.txt" which gives me an output with
one line of 5237664526 chars long, not ideal ;(

is there something I can do to adjust that tr statement so that CR's / newlines which
are immedeiatly preceded by a right bracket are ignored ?
or if there's a way of doing it without tr, I might even attempt perl ;)


thanks
	Ray ...



More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell