sed and comma-delimited file
Julian Stacey
jhs at berklix.org
Tue Sep 19 11:09:53 PDT 2006
Reference:
> From: "SigmaX asdf" <fydernix at gmail.com>
> Date: Tue, 19 Sep 2006 12:26:54 -0400
> Message-id: <c04d7e300609190926t1e5dce14wea7ef1a16ccf9af1 at 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
More information about the freebsd-stable
mailing list