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] Gawk query

[ILUG] Gawk query

Paschal Nee pnee at toombeola.com
Thu Aug 23 17:03:34 IST 2007


Hi,

Seems like a standard enough query but is there a way to get gawk to
recognise fields that are enclosed by a delimiter as single fields.

An example:

10.129.141.1 - - [23/Aug/2007:16:06:14 +0100] "GET /hh HTTP/1.1" 200 1763
10.129.141.1 - - [23/Aug/2007:16:06:14 +0100] "GET /hy HTTP/1.1" 200 1763
10.129.141.1 - - [23/Aug/2007:16:06:14 +0100] "GET /hz HTTP/1.1" 200 1763
10.129.141.1 - - [23/Aug/2007:16:06:14 +0100] "GET /hf HTTP/1.1" 200 1763

Running gawk '{for (i=0;i<NF;i++) print $i}' on the above would get you

10.129.141.1
-
-
[23/Aug/2007:16:06:14
+0100]
"GET
/hh
HTTP/1.1"
200

whereas what I'm looking for would be

10.129.141.1
-
-
23/Aug/2007:16:06:14 +0100
GET /hh HTTP/1.1
200
1763

i.e. recognising that [] and "" enclose single fields.

There are some kludgey workarounds on the web - if could be done
"right" I'd rather do it that way.  Otherwise I suppose something a
bit more powerful than gawk might be called for.

Thanks,
Paschal.



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