transponse row to coloumn output


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers transponse row to coloumn output
# 1  
Old 02-21-2012
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
# 2  
Old 02-21-2012
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 05:15 AM..
# 3  
Old 02-21-2012
greaaaaat wrok thank you Smilie
# 4  
Old 02-21-2012
I have posted a matrix transpose script here few days ago:
https://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}

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How do we display specific row of an output from bottom given line number?

I pass a number to my script. Passing "1" below. ./getfile.sh 1 echo "User entered: $1" ls -ltr *.conf | sed -n '$p' I wish to use ls -ltr i.e list files in ascending order of time the latest showing at the bottom of the output. Number 1 should get me the last row of ls -ltr output i.e... (9 Replies)
Discussion started by: mohtashims
9 Replies

2. Shell Programming and Scripting

Transpose the 2nd coloumn in every fourth row three times....

I have several csv files, each hundreds of rows with the following layout "","SEQ ID No. 1 Subject # 20" "BPM neg.:",68.83 "BPM normal:",68.48 "SEQ ID No. 1 Subject # 20",79.33 "","SEQ ID No. 10 Subject # 20" "BPM neg.:",68.05 "BPM normal:",68.58 "SEQ ID No. 10 Subject # 20",81.63... (6 Replies)
Discussion started by: bertbrutzel
6 Replies

3. Shell Programming and Scripting

Output Row if Third Column is Larger

Hi, I am fairly new to Unix scripting. We are running Solaris 5.10. I have the following question: Assume a text file with one text column, followed by 2 integer columns. How would I generate a script or, preferably, a command that will output the rows in which the value of the third... (6 Replies)
Discussion started by: QZ1
6 Replies

4. Shell Programming and Scripting

Output mean and standard deviation of a row

I have a file that looks that this: 820 890 530 1650 1600 1800 1850 1900 2270 1640 2300 1670 2080 2200 2350 1150 1630 2210 I would like to output the mean and standard deviation of each row so that my final output would look like this 820 890 530 746.667 155.849 1650 1600 1800... (5 Replies)
Discussion started by: kayak
5 Replies

5. Shell Programming and Scripting

Column to row output

Hello All, i have a file with the contents like shown below Name = POLICY1 Selected = 1 Written = 0 Name = POLICY2 Selected = 6 Written = 8 Name = POLICY3 Selected = 4 Written = 26 I want the output to be... (5 Replies)
Discussion started by: vinredmac
5 Replies

6. Shell Programming and Scripting

convert a column to row output?

Getting tired of cut-and-paste...so I thought I would post a question. how do I change this column output to a single row? from this: # vgdisplay -v /dev/vgeva05 | grep dsk | awk '{print $3}' /dev/dsk/c6t0d5 /dev/dsk/c11t0d5 /dev/dsk/c15t0d5 /dev/dsk/c18t0d5 /dev/dsk/c7t0d5... (8 Replies)
Discussion started by: mr_manny
8 Replies

7. Shell Programming and Scripting

top output for six processes with the same name, output changed from column to row

Hi, I have a system under test, and I use a script that does a ps. The output, is in the following format, it's basically the timestamp, followed by the rss and vsize. 09:03:57 68404 183656 68312 181944 69860 217360 67536 182564 69072 183172 69032 199276 09:04:27 68752 183292 70000 189020... (5 Replies)
Discussion started by: Bloke
5 Replies

8. UNIX for Dummies Questions & Answers

How to copy one coloumn from one file to another

Hi All, I have two files in which i want to copy one coloumn from one file to another such that it appears as a separate coloumn in the other file.Please note there already exists a coloumn in the other file.For eg in file 1(first file) i have 12 23 35 in file 2(other file) i have 34 45... (2 Replies)
Discussion started by: navjotsingh
2 Replies

9. Shell Programming and Scripting

Extend the Output length of a row

hi all, I use shell script to fetch some data's from my sybase database and i redirect my output to a file , i have some disorder in my file.my current o/p file looks like, firstrecord|secondrecord|thirdrecord|fourthrecord|fivthrecord|s ixhrecord|seventhrecord| ... (10 Replies)
Discussion started by: ulin
10 Replies

10. Shell Programming and Scripting

How To display second coloumn values

i have a file like this ..... empno ----- ename ----- job 1 ----- scott----- manager 2----- ford----- salesman 3 ----- mark---- president in this i wanna display second column means ename... (6 Replies)
Discussion started by: naughty21
6 Replies
Login or Register to Ask a Question