Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Jan 2006 17:19:24 -0600
From:      Don Hinton <don.hinton@vanderbilt.edu>
To:        freebsd-questions@freebsd.org
Cc:        Alexandre Vieira <nullpt@gmail.com>
Subject:   Re: awk question
Message-ID:  <200601201719.29153.don.hinton@vanderbilt.edu>
In-Reply-To: <755cb9fc0601201459v643bf464i892ef3efc68dc788@mail.gmail.com>
References:  <755cb9fc0601201459v643bf464i892ef3efc68dc788@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--nextPart2029823.R1IqImfhSs
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hi Alexandre:

On Friday 20 January 2006 16:59, Alexandre Vieira wrote:
> 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?

Sure.  Here's a link to the online awk documentation section on field=20
seperators...

http://www.gnu.org/software/gawk/manual/html_node/Field-Separators.html#Fie=
ld-Separators

ciao...
don


>
> 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.
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to
> "freebsd-questions-unsubscribe@freebsd.org"

=2D-=20
Don Hinton <don.hinton at vanderbilt.edu>      tel: 615.480.5667
ISIS, Vanderbilt University                  skype: donhinton
http://people.vanderbilt.edu/~don.hinton/

--nextPart2029823.R1IqImfhSs
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (FreeBSD)

iD8DBQBD0XAB0U0xbM5cLs0RAj0mAJ9R98okWZ/XiAs0yeIhzNrVOOXlwgCgwURM
L9KZx6YmMxAgENEMPVLLDCw=
=Uoxw
-----END PGP SIGNATURE-----

--nextPart2029823.R1IqImfhSs--



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