From: Richard Miller <9fans@hamnavoe.com>
To: 9fans@9fans.net
Subject: Re: [9fans] rows to cols?
Date: Sat, 14 Nov 2009 09:43:45 +0000 [thread overview]
Message-ID: <ebdfcf288f3ec91063fd3c0e59ae2983@hamnavoe.com> (raw)
In-Reply-To: <426EC536-0207-47C8-93B9-C16623F895FC@mac.com>
> Wow.
> Excellent us of tools.
It's the sort of thing I used to give as an exercise to students.
> The smallest arbitrary-columns answer I could come up with was:
> awk '{if(m < NF)m=NF;for(i=1;i<=NF;i++)r[NR, i]=$i}END {for(i=1;i<=m;i+
> +){for(j=1;j<=NR;j++)printf "%s ", r[j,i];print ""}}' t
Explicit looping looks so strenuous.
To make the tr|pr method more general, you can count columns first with
sed 1q | wc -b
or if you like
awk '{print NF;exit}'
Counting rows is left as an exercise to the reader ...
next prev parent reply other threads:[~2009-11-14 9:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-13 7:39 Peter A. Cejchan
2009-11-13 8:44 ` Richard Miller
2009-11-13 9:36 ` Tharaneedharan Vilwanathan
2009-11-13 23:53 ` dave.l
2009-11-14 9:43 ` Richard Miller [this message]
2009-11-14 11:27 ` dave.l
2009-11-14 4:43 ` Lyndon Nerenberg (VE6BBM/VE7TFX)
[not found] <<372549f4a1e93be164e3f5016203c1c3@yyc.orthanc.ca>
2009-11-14 15:11 ` erik quanstrom
2009-11-14 23:23 ` Lyndon Nerenberg (VE6BBM/VE7TFX)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ebdfcf288f3ec91063fd3c0e59ae2983@hamnavoe.com \
--to=9fans@hamnavoe.com \
--cc=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).