From owner-freebsd-stable@FreeBSD.ORG Fri Sep 22 05:09:25 2006 Return-Path: X-Original-To: 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 F0DE816A40F for ; Fri, 22 Sep 2006 05:09:25 +0000 (UTC) (envelope-from fcash@ocis.net) Received: from smtp.sd73.bc.ca (smtp.sd73.bc.ca [142.24.13.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id 98FD843D77 for ; Fri, 22 Sep 2006 05:09:09 +0000 (GMT) (envelope-from fcash@ocis.net) Received: from localhost (localhost [127.0.0.1]) by localhost.sd73.bc.ca (Postfix) with ESMTP id 8D8718A00C0; Thu, 21 Sep 2006 22:09:09 -0700 (PDT) Received: from smtp.sd73.bc.ca ([127.0.0.1]) by localhost (smtp.sd73.bc.ca [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 77744-37; Thu, 21 Sep 2006 22:08:58 -0700 (PDT) Received: from webmail.sd73.bc.ca (unknown [10.10.10.17]) by smtp.sd73.bc.ca (Postfix) with ESMTP id 72B098A0025; Thu, 21 Sep 2006 22:08:49 -0700 (PDT) Received: from 24.70.153.246 (SquirrelMail authenticated user fcash) by webmail.sd73.bc.ca with HTTP; Thu, 21 Sep 2006 22:08:57 -0700 (PDT) Message-ID: <60471.24.70.153.246.1158901737.squirrel@webmail.sd73.bc.ca> In-Reply-To: <002101c6dc46$470b1d50$0000fea9@gsicomp.on.ca> References: <54894.192.168.0.10.1158706436.squirrel@webmail.sd73.bc.ca> <002101c6dc46$470b1d50$0000fea9@gsicomp.on.ca> Date: Thu, 21 Sep 2006 22:08:57 -0700 (PDT) From: "Freddie Cash" To: "Matt Emmerton" User-Agent: SquirrelMail/1.5.1 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new using ClamAV at sd73.bc.ca Cc: 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: Fri, 22 Sep 2006 05:09:26 -0000 On Tue, September 19, 2006 4:49 pm, Matt Emmerton wrote: >> 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 [shrug] It uses cut, which I've never used or even heard of??? :) ---- Freddie Cash fcash@ocis.net