Convert multiple columns to multiple lines

Convert multiple columns to multiple lines

am 07.12.2007 18:50:19 von dave

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

am 07.12.2007 19:07:09 von Icarus Sparry

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

am 07.12.2007 19:35:43 von cichomitiko

"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

am 07.12.2007 20:38:10 von Janis Papanagnou

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