From owner-freebsd-questions@FreeBSD.ORG Sun Nov 2 12:52:52 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 E94C4106568E for ; Sun, 2 Nov 2008 12:52:52 +0000 (UTC) (envelope-from jonathan+freebsd-questions@hst.org.za) Received: from hermes.hst.org.za (onix.hst.org.za [209.203.2.133]) by mx1.freebsd.org (Postfix) with ESMTP id 2C9658FC12 for ; Sun, 2 Nov 2008 12:52:51 +0000 (UTC) (envelope-from jonathan+freebsd-questions@hst.org.za) Received: from giles (dsl-145-38-45.telkomadsl.co.za [165.145.38.45]) (authenticated bits=0) by hermes.hst.org.za (8.13.8/8.13.8) with ESMTP id mA2CgXjA062145 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 2 Nov 2008 14:42:40 +0200 (SAST) (envelope-from jonathan+freebsd-questions@hst.org.za) From: Jonathan McKeown To: freebsd-questions@freebsd.org Date: Sun, 2 Nov 2008 14:53:01 +0200 User-Agent: KMail/1.9.7 References: <2daa8b4e0811011821q210ae3a5j8f612a0fc79e8844@mail.gmail.com> In-Reply-To: <2daa8b4e0811011821q210ae3a5j8f612a0fc79e8844@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200811021453.01646.jonathan+freebsd-questions@hst.org.za> X-Spam-Score: -3.479 () AWL,BAYES_00 X-Scanned-By: MIMEDefang 2.61 on 209.203.2.133 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 12:52:53 -0000 On Sunday 02 November 2008 03:21:55 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 Are you dead set on using awk(1)? Because my first thought would be rs(1). cat inputfile | rs 0 7 To turn your space-separated entries into 7 columns. You may need some fiddling about (to avoid running out of memory, space on the line, etc). This is one of my top three sadly-neglected BSD commands everyone should know more about, along with lam(1) and jot(1). Jonathan