OT: Shell Script using Awk

Jonathan McKeown jonathan+freebsd-questions at hst.org.za
Sun Nov 2 04:52:53 PST 2008

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).


More information about the freebsd-questions mailing list