Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Nov 2008 21:03:27 -0800
From:      "David Allen" <the.real.david.allen@gmail.com>
To:        "Gary Newcombe" <gary@pattersonsoftware.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: OT: Shell Script using Awk
Message-ID:  <2daa8b4e0811012203u1562cf47h3b92391cbcf77203@mail.gmail.com>
In-Reply-To: <20081102143753.d1f66ad9.gary@pattersonsoftware.com>
References:  <2daa8b4e0811011821q210ae3a5j8f612a0fc79e8844@mail.gmail.com> <20081102143753.d1f66ad9.gary@pattersonsoftware.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 11/1/08, Gary Newcombe <gary@pattersonsoftware.com> wrote:
> On Sat, 1 Nov 2008 18:21:55 -0700, "David Allen"
> <the.real.david.allen@gmail.com> 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<NF;i+=7) print
> $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.



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