Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-21-2012
Registered User
 
Join Date: May 2011
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
transponse row to coloumn output

dears

i have row data as below:

========================================================================================
Session Count: 24580
Session Count: 13426
Session Count: 22533
Session Count: 0
Session Count: 0
Session Count: 15036
Session Count: 11625
Session Count: 6942
Session Count: 11958
Session Count: 25082
Session Count: 22489
======================================================
Session Count: 24354
Session Count: 13457
Session Count: 22425
Session Count: 0
Session Count: 0
Session Count: 14913
Session Count: 11553
Session Count: 6810
Session Count: 11714
Session Count: 24920
Session Count: 22212
=======================================================


and i want to make the output like this:


Session Count: Session Count: Session Count: Session Count: Session Count: Session Count: Session Count: Session Count: Session Count: Session Count: Session Count:
24580 13426 22533 0 0 15036 11625 6942 11958 25082 22489
============== ==========================================================================
Session Count: Session Count: Session Count: Session Count: Session Count: Session Count: Session Count: Session Count: Session Count: Session Count: Session Count:
24354 13457 22425 0 0 14913 11553 6810 11714 24920 22212
============== ==========================================================================

so any one can help me in getting a script can do this?

thank you
Sponsored Links
    #2  
Old 02-21-2012
Scrutinizer's Avatar
Moderator
 
Join Date: Nov 2008
Location: Amsterdam
Posts: 7,350
Thanks: 144
Thanked 1,756 Times in 1,593 Posts
Try:

Code:
awk -F': ' '/^=/{print p ORS q ORS $0;p=q=x;next}{p=p $1 FS;q=q $2 OFS}' infile

-or-

Code:
awk -F ': ' 'NR==1{next}/^=/{print p ORS q ORS $0;p=q=x;next}{p=p $1 FS;q=q $2 OFS}' infile


Last edited by Scrutinizer; 02-21-2012 at 04:15 AM..
Sponsored Links
    #3  
Old 02-21-2012
Registered User
 
Join Date: May 2011
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
greaaaaat wrok thank you
    #4  
Old 02-21-2012
complex.invoke's Avatar
Registered User
 
Join Date: Nov 2009
Location: BeiJing China
Posts: 234
Thanks: 6
Thanked 17 Times in 8 Posts
I have posted a matrix transpose script here few days ago:
http://www.unix.com/shell-programmin...into-rows.html

Code:
#!/bin/bash 
 
transpose() 
{ 
  awk ' 
      { 
              if (max_nf<NF) 
                    max_nf=NF 
              max_nr=NR 
              for (x=1; x<=NF; ++x) 
                     vector[x, NR]=$x 
      } 
  END { 
              for (x=1; x<=max_nf; ++x) { 
                   for (y=1; y<=max_nr; ++y) 
                        printf("%s ", vector[x, y]) 
                   printf("\n") 
               } 
          }'  ${1} 
} 
 
transpose ${1}

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
passing coloumn value to system function in awk max_hammer UNIX for Dummies Questions & Answers 2 07-07-2011 08:10 AM
How to copy one coloumn from one file to another navjotsingh UNIX for Dummies Questions & Answers 2 02-12-2009 12:39 PM
How To display second coloumn values naughty21 Shell Programming and Scripting 6 07-22-2008 09:42 AM
how to make a line BLINKING in output and also how to increase font size in output mail2sant Shell Programming and Scripting 3 04-14-2008 07:30 AM
How to change Raw data to Coloumn data fields Nayanajith Shell Programming and Scripting 1 08-29-2006 01:23 AM



All times are GMT -4. The time now is 12:32 PM.