From owner-freebsd-questions@FreeBSD.ORG Sun Nov 2 05:03:28 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 79EB4106567C for ; Sun, 2 Nov 2008 05:03:28 +0000 (UTC) (envelope-from the.real.david.allen@gmail.com) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.236]) by mx1.freebsd.org (Postfix) with ESMTP id 4C3228FC17 for ; Sun, 2 Nov 2008 05:03:28 +0000 (UTC) (envelope-from the.real.david.allen@gmail.com) Received: by rv-out-0506.google.com with SMTP id b25so1848270rvf.43 for ; Sat, 01 Nov 2008 22:03:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=XRn8mpnmcWUWn/gDO8AE7EzJvQ9BzOgjIcD2aU8HmQU=; b=bKzmhZi0dOgIe39DoDszOyJCvEAoxjoQ/ODKQ8b9PRjV6pi8B3N28YN4zBv/akZOpC RUGc8XOYUkrKL5O4j6xxG26LBuBHl6//6LaT8VAJ2hJO0nOHb5zEI7U5/axrdpKhmyjv oQtJMljgAgnBBPkSb78PHOCup7JDxhgp9oxuQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=MbzO3z+Zq3MpM2n1C/XmEbHijQ03fFQSBK38oXEP/moKx6jfVnibhmGKUT2d08LypA klcAjcz64/OZw2+59YhOqzyRk4xczAvCt4jGlYsGg6cDR5DbueNaPuanyhMUS5QANSlM /lJHrvV7kX39T3fTDfr9WSfvvokR4PBCrmP4s= Received: by 10.142.128.6 with SMTP id a6mr6419441wfd.10.1225602207794; Sat, 01 Nov 2008 22:03:27 -0700 (PDT) Received: by 10.143.18.2 with HTTP; Sat, 1 Nov 2008 22:03:27 -0700 (PDT) Message-ID: <2daa8b4e0811012203u1562cf47h3b92391cbcf77203@mail.gmail.com> Date: Sat, 1 Nov 2008 21:03:27 -0800 From: "David Allen" To: "Gary Newcombe" In-Reply-To: <20081102143753.d1f66ad9.gary@pattersonsoftware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <2daa8b4e0811011821q210ae3a5j8f612a0fc79e8844@mail.gmail.com> <20081102143753.d1f66ad9.gary@pattersonsoftware.com> Cc: freebsd-questions@freebsd.org Subject: Re: OT: Shell Script using Awk X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Nov 2008 05:03:28 -0000 On 11/1/08, Gary Newcombe wrote: > On Sat, 1 Nov 2008 18:21:55 -0700, "David Allen" > wrote: > >> My apologies for asking on this list, but I'm stuck without Perl and need >> to use awk to generate a report. >> >> I'm working with a large data set spread across multiple files, but to >> keep things simple, say I have A Very Long String that containing records, >> each delimited by a single space. I need to print those records in >> columnar format, but with only 7 columns per line: >> >> record1 record2 record3 record4 record5 record6 record7 >> record08 record09 record10 record11 record12 record13 record14 >> ... >> >> Should be simple, but I'm getting nowhere. > > Is this what you're after? > > $ cat input > col1 col2 col3 col4 col5 col6 col7 col8 col9 col10 col11 col12 col13 col14 > col15 col16 .... > > cat input | awk -F\ '{for (i=1;i $i,$(i+1),$(i+2),$(i+3),$(i+4),$(i+5),$(i+6) }' Bingo! That was what similar to what I was starting with before going off on a tangent. Seems I screwed up the syntax and gave up too early. Thanks, Gary.