LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-08-2011, 05:32 AM   #1
Mehidi
LQ Newbie
 
Registered: Jul 2011
Posts: 6

Rep: Reputation: Disabled
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.
 
Old 07-08-2011, 05:53 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[ask awk] remove certain row in a column dhodho Programming 18 06-08-2010 09:36 AM
transpose row to column? resolute155 Programming 3 09-07-2009 02:29 PM
how to get the second column and first row data from a file??? loplayers Linux - Newbie 3 11-05-2007 07:35 PM
Transposing a column into a row mayyash Linux - General 1 09-30-2005 02:23 AM
How to write the contents of a column as a row in linux markraem Linux - Software 4 07-17-2004 07:35 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration