Convert multiple columns to multiple lines
I have a program which outputs about 100 columns of data. The first 6
are shown:
UTC 10:53:40 power 30 elevation 23
I want to convert that so it outputs
UCT 10:53:40
power 30
elevation 23
...
Any suggestions?
Re: Convert multiple columns to multiple lines
On Fri, 07 Dec 2007 17:50:19 +0000, Dave wrote:
> I have a program which outputs about 100 columns of data. The first 6
> are shown:
>
>
> UTC 10:53:40 power 30 elevation 23
>
> I want to convert that so it outputs
>
> UCT 10:53:40
> power 30
> elevation 23
> ..
>
> Any suggestions?
Well, if you want to split them pairwise, you could use
awk '{for(i=1;i<NF;i+=2) print $i,$(i+1); }'
If you need more, e.g. you have an odd number of columns, or pairwise is
not exactly what you want then you will need to give us more information.
Re: Convert multiple columns to multiple lines
"Dave" wrote ...
>I have a program which outputs about 100 columns of data. The first 6 are
>shown:
>
>
> UTC 10:53:40 power 30 elevation 23
>
> I want to convert that so it outputs
>
> UCT 10:53:40
> power 30
> elevation 23
> ..
With GNU Awk:
awk 'ORS=NR%2?FS:"\n"' RS="[ \n]" filename
Dimitre
Re: Convert multiple columns to multiple lines
Dave wrote:
> I have a program which outputs about 100 columns of data. The first 6
> are shown:
>
>
> UTC 10:53:40 power 30 elevation 23
>
> I want to convert that so it outputs
>
> UCT 10:53:40
> power 30
> elevation 23
> ..
>
> Any suggestions?
printf "%s %s\n" $( program_that_outputs_data )
Janis