OT: Shell Script using Awk
Jeremy Chadwick
koitsu at FreeBSD.org
Sat Nov 1 19:03:47 PDT 2008
On Sat, Nov 01, 2008 at 06:21:55PM -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.
$ cat input
col1 col2 col3 col4 col5 col6 col7 col8 col9 col10 col11 col12 col13 col14
$ cat output.awk
{
print $1 " " $2 " " $3 " " $4 " " $5 " " $6 " " $7
print $8 " " $9 " " $10 " " $11 " " $12 " " $13 " " $14
}
$ cat intput | awk -f output.awk
col1 col2 col3 col4 col5 col6 col7
col8 col9 col10 col11 col12 col13 col14
--
| Jeremy Chadwick jdc at parodius.com |
| Parodius Networking http://www.parodius.com/ |
| UNIX Systems Administrator Mountain View, CA, USA |
| Making life hard for others since 1977. PGP: 4BD6C0CB |
More information about the freebsd-questions
mailing list