Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Sep 2006 19:49:42 -0400
From:      "Matt Emmerton" <matt@gsicomp.on.ca>
To:        "Freddie Cash" <fcash@ocis.net>, "SigmaX asdf" <fydernix@gmail.com>
Cc:        stable@freebsd.org
Subject:   Re: sed and comma-delimited file
Message-ID:  <002101c6dc46$470b1d50$0000fea9@gsicomp.on.ca>
References:  <c04d7e300609190926t1e5dce14wea7ef1a16ccf9af1@mail.gmail.com> <54894.192.168.0.10.1158706436.squirrel@webmail.sd73.bc.ca>

next in thread | previous in thread | raw e-mail | index | archive | help
> On Tue, September 19, 2006 9:26 am, SigmaX asdf wrote:
> > I have a series of comma-delimited text files with fourteen columns
> > of data and several hundred rows.  I want to use a short shell script
> > to strip them of the last 9 columns, leaving the same file but with
> > just five of its columns.  I can do it in C++, but that seems like
> > overkill.  How would I go about doing it with sed or a similar
> > utility?
> 
> cat file | awk -F"," '{ printf "%s,%s,%s,%s,%s\n",$1,$2,$3,$4,$5  }' >
> newfile

What's wrong with this?

cat file | cut -f-5 -c';' > newfile

--
Matt Emmerton



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?002101c6dc46$470b1d50$0000fea9>