LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 10-25-2007, 01:42 AM   #1
bharatbsharma
Member
 
Registered: Oct 2007
Posts: 33

Rep: Reputation: 15
Column into rows


i/p file
A W

B X

C Y

D Z



how do i get o/p file like this , using awk :

A B C D
W X Y Z
 
Old 10-25-2007, 02:23 AM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 240Reputation: 240Reputation: 240
from somewhere
Code:
awk '
 { for (j=1; j<=NF; j++)  b[NR,j] = $j}
     NF>n { n = NF }
END {
    t = NR;
    for(j=1; j<=n; j++) {
     s=b[1,j];
     for(i=2; i<=t; i++)
	 s=s OFS b[i,j];
     print s
    }
}'  "file"
 
  


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
How to convert 1 column into several rows in Linux? markraem Linux - Software 9 03-30-2010 11:24 AM
How to define # of rows in a table royeo Linux - Software 3 11-07-2006 06:52 PM
Parsing rows and column data from a file using perl dav_y2k Programming 1 10-08-2006 11:57 AM
columns & rows Ammad Linux - General 1 08-08-2005 04:02 AM
rows and columns digitalgravy Linux - General 2 03-16-2004 06:47 PM


All times are GMT -5. The time now is 09:48 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration