Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Sep 2006 20:09:25 +0200
From:      "Julian Stacey" <jhs@berklix.org>
To:        "SigmaX asdf" <fydernix@gmail.com>
Cc:        freebsd-stable@freebsd.org
Subject:   Re: sed and comma-delimited file 
Message-ID:  <200609191809.k8JI9Pva086909@fire.jhs.private>
In-Reply-To: Your message of "Tue, 19 Sep 2006 12:26:54 EDT." <c04d7e300609190926t1e5dce14wea7ef1a16ccf9af1@mail.gmail.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
Reference:
> From:		"SigmaX asdf" <fydernix@gmail.com> 
> Date:		Tue, 19 Sep 2006 12:26:54 -0400 
> Message-id:	<c04d7e300609190926t1e5dce14wea7ef1a16ccf9af1@mail.gmail.com> 

"SigmaX asdf" wrote:
> Yo;
> 
> 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?

awk 	!
/usr/ports/lang/gawk  exists too.
PS
Here's odd notes from my syntax file, not exactly appropriate to you,
but near enough to give ideas with	`man awk' for ref, & `fun' to learn ;-)
----
 awk '{printf "rm -f %s ; ln -s ..%s %s\n",$1,$3,$1}' < /tmp/x
 awk -F = '{printf "%s\n",$1}' < /tmp/t
 awk --field-separator # '{printf "%s\n",$1}'
 awk -F # '{printf "%s\n",$1}'                  # 5.0 has no --field-separator
 awk '{printf "%s\n",$1}' < distfiles.dump
 find /etc /var /usr -type l | sort | xargs ls -l | \
         awk '{printf "%s -> %s\n",$9,$11}'     # List all links

-- 
Julian Stacey.  BSD Unix C Net Consultancy, Munich/Muenchen  http://berklix.com
Mail Ascii, not HTML.		Ihr Rauch = mein allergischer Kopfschmerz.
	Don't buy it ! Get it free !  http://berklix.org/free-software



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