Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Jan 2006 22:59:16 +0000
From:      Alexandre Vieira <nullpt@gmail.com>
To:        freebsd-questions@freebsd.org
Subject:   awk question
Message-ID:  <755cb9fc0601201459v643bf464i892ef3efc68dc788@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Hello folks,

I'm making a script to generate some statistics for a batch job and I'm
stuck with awk.

For example:

%echo 1 2 3 4 5 6 | awk {'print $1 $2 $3 $4 $5 $6'}

it will output:

1 2 3 4 5 6

I want to tokenize a string with another separating char (the : char):

%echo 1:2:3:4:5:6

and with awk to output:

1 2 3 4 5 6

Is there any way of doing this?

Real example:

I have a log file with the following output:
2006-01-20 - 20:01:07 - Some text
2006-01-20 - 20:01:15 - Some text
2006-01-20 - 20:01:38 - Some text
(...)

and since I'm generating hourly stats I need to match the "20" which is in =
a
string "20:01:07" that is separated by the char ":".

I hope I've been clear.

Thanks for your help.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?755cb9fc0601201459v643bf464i892ef3efc68dc788>