Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Mar 2004 15:03:46 +0000 (GMT)
From:      Jan Grant <Jan.Grant@bristol.ac.uk>
To:        =?iso-8859-2?Q?Roub=ED=E8ek_Zden=ECk_=28T-Systems_PragoNet=29?= <Zdenek.Roubicek@pragonet.cz>
Cc:        questions <questions@freebsd.org>
Subject:   Re: Problem with sed and awk
Message-ID:  <Pine.GSO.4.58.0403011501500.12268@mail.ilrt.bris.ac.uk>
In-Reply-To: <9256D57F598E6C41B288AA7DB94F29C901C2D69A@pgnmail1.pgnaplikace.cz>
References:  <9256D57F598E6C41B288AA7DB94F29C901C2D69A@pgnmail1.pgnaplikace.cz>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 26 Feb 2004, [iso-8859-2] Roub=ED?ek Zden?k (T-Systems PragoNet) wr=
ote:

>
>  Hello questions
>
>  Any idea what I am missing?
>
> >cat test
> 1;1
> 2;2
> >awk -F ';' '{print $1}'
> 1
> 2
> >awk -F ' FS=3D";" {print $1}'
> 1;1
> 2
> >

The FS=3D";" is a pattern expression that is used to match the first line
of input, after it has already been split into fields. It evaluates true
so the block it guards is always run. After the first line has been
dealt with, future lines will be split using the new FS setting. As
another poster supplied, slap the FS setting in a BEGIN-guarded block.

--=20
jan grant, ILRT, University of Bristol. http://www.ilrt.bris.ac.uk/
Tel +44(0)117 9287088 Fax +44 (0)117 9287112 http://ioctl.org/jan/
If it's broken really badly - don't fix it either.



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