[ILUG] [OT] awk FS question

Mark Webb mark.webb at Trintech.com
Mon Sep 11 18:15:47 IST 2000


> -----Original Message-----
> From: Paul Jakma [mailto:paulj at itg.ie]
> Sent: 11/September/2000 17:48
> To: ilug at linux.ie
> Subject: [ILUG] [OT] awk FS question
> 
> 
> doc's for awk say the FS can be set to a regexp. I want FS to split
> fields on spaces, tabs, etc and '/'.
> 
> I've tried 
> 
> FS = "[:space]\/"
>    = "[[:space:]\/]"
>    = "[\ /]"
>    = "/[[:space:]/]"
>    = "/[[\/[:space:]]"
> 
> and loads of combinations thereof.. just can not get it to fscking do
> what i want.. arrgggg..

[mwebb at linux ~]$ cat m
linewithnospaces
a space tab/slash:colon

       ^___ tab

[mwebb at linux ~]$ cat p.awk 
#
#
BEGIN   { FS="[ \t/]" }

        { print "[", $1, "] [", $2, "] [", $3, "] [", $4, "]" }

END     { }

[mwebb at linux ~]$ awk -f p.awk m
[ linewithnospaces ] [  ] [  ] [  ]
[ a ] [ space ] [ tab ] [ slash:colon ]

Easier than perl...

-Mark.




More information about the ILUG mailing list