LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Transposing only part of row into column (https://www.linuxquestions.org/questions/programming-9/transposing-only-part-of-row-into-column-890567/)

Mehidi 07-08-2011 05:32 AM

Transposing only part of row into column
 
I am trying to transpose the following row:

x1 x2 x3 x4

into

x1 X2
x3 x4

With tr ' ' '\n' < file I can select all columns to become separate rows, but as you see x3 and x4 have to be grouped when transposing....Or should I use awk for this one? Couldn't find solutions in the former transpose questions, so suggestions would be very welcome.

druuna 07-08-2011 05:53 AM

Hi,

Is the capital X (x2 vs X2) a typo?

If it is:
Code:

awk '{ print $1, $2 "\n" $3, $4 }' infile
If not:
Code:

awk '{ print $1, toupper($2) "\n" $3, $4 }' infile
Hope this helps.


All times are GMT -5. The time now is 02:39 AM.