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] Sed/tex processing Question

[ILUG] Sed/tex processing Question

Pádraig Brady P at draigBrady.com
Wed Mar 11 00:05:45 GMT 2009


rory.winston at gmail.com wrote:
> Hi All
> 
> I have a sed question: currently I am using sed to preprocess some
> garbage collection log files produced by Java.
> There are 10 pieces on information on every line that I would like to
> extract. I have just knocked up a large and ugly sed command to do this:
> 
> # Typical line
> # 7.181: [GC 7.181: [ParNew: 6193K->101K(6528K), 0.0031050 secs]
> 8470K->2692K(64832K), 0.0031680 secs]
> 
> $ sed -n "/GC/{s/^\([0-9]\+\.[0-9]\+\): \[GC \([0-9]\+\.[0-9]\+\): \[ParNew
> : \([0-9]\+\)K->\([0-9]\+\)K(\([0-9]\+\)K), \([0-9]\+\.[0-9]\+\) secs\]
> \([0-9]\+\)K->\([0-9]\+\)K(
> \([0-9]\+\)K), \([0-9]\+\.[0-9]\+\)
> secs\]/\1,\2,\3,\4,\5,\6,\7,\8,\9/gp}" logfile
> 
> This has a fatal flaw, in that I have exhausted the maximum number of
> backreferences available. Does anyone know a better way to do this?

How about transforming the delimiters?

sed -n '/GC/s/[^0-9.]\+/ /gp'

cheers,
Pádraig.



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