From owner-freebsd-stable@FreeBSD.ORG Tue Sep 19 18:09:52 2006 Return-Path: X-Original-To: freebsd-stable@freebsd.org Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C721A16A49E for ; Tue, 19 Sep 2006 18:09:52 +0000 (UTC) (envelope-from jhs@flat.berklix.net) Received: from thin.berklix.org (thin.berklix.org [194.246.123.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id BCBDB43DFC for ; Tue, 19 Sep 2006 18:09:19 +0000 (GMT) (envelope-from jhs@flat.berklix.net) Received: from js.berklix.net (p549A4C39.dip.t-dialin.net [84.154.76.57]) (authenticated bits=128) by thin.berklix.org (8.12.11/8.12.11) with ESMTP id k8JI9HKc098830; Tue, 19 Sep 2006 20:09:17 +0200 (CEST) (envelope-from jhs@flat.berklix.net) Received: from fire.jhs.private (fire.jhs.private [192.168.91.41]) by js.berklix.net (8.13.6/8.13.6) with ESMTP id k8JI9P02054170; Tue, 19 Sep 2006 20:09:26 +0200 (CEST) (envelope-from jhs@flat.berklix.net) Received: from fire.jhs.private (localhost [127.0.0.1]) by fire.jhs.private (8.13.6/8.13.6) with ESMTP id k8JI9Pva086909; Tue, 19 Sep 2006 20:09:25 +0200 (CEST) (envelope-from jhs@fire.jhs.private) Message-Id: <200609191809.k8JI9Pva086909@fire.jhs.private> To: "SigmaX asdf" From: "Julian Stacey" Organization: http://berklix.com BSD Unix C Net Consultancy, Munich/Muenchen User-agent: EXMH http://beedub.com/exmh/ on FreeBSD http://freebsd.org X-URL: http://berklix.com X-Fallback: jhs@mail.brierdr.com, jhs@freebsd.org, jhs@berklix.net In-reply-to: Your message of "Tue, 19 Sep 2006 12:26:54 EDT." Date: Tue, 19 Sep 2006 20:09:25 +0200 Sender: jhs@flat.berklix.net Cc: freebsd-stable@freebsd.org Subject: Re: sed and comma-delimited file X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Sep 2006 18:09:53 -0000 Reference: > From: "SigmaX asdf" > Date: Tue, 19 Sep 2006 12:26:54 -0400 > Message-id: "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