awk question

Don Hinton don.hinton at vanderbilt.edu
Thu Jul 26 21:12:02 UTC 2007


On Thursday 26 July 2007 15:26:02 Peter Boosten wrote:
> P.U.Kruppa wrote:
> > Hi (and sorry for this slightly OT question),
> >
> > I would like to extract the second last field of each line of a file
> > called user.csv .
> > So I try
> >
> >     > awk '{print $(NF-1)}' user.csv
> >
> >     awk: trying to access out of range field -1
> >      input record number 1, file user.csv
> >      source line number 1
> >
> > Obviously $(NF-1) doesn't do the trick. Any better idea?
>
> Hmmm, works for me it does...

Me too, except of course if the first line of user.cvs is blank...

>
> Peter



-- 
Don Hinton <don.hinton at vanderbilt.edu> or <hintonda at gmail.com>
Institute for Software Integrated Systems (ISIS), Vanderbilt University
tel: 615.480.5667 or 615.870.9728


More information about the freebsd-questions mailing list