regarding about printing row to column


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting regarding about printing row to column
# 1  
Old 07-15-2009
regarding about printing row to column

Hello,
I got data like that,

Code:
[id]=111
A= alpha
B= 1
C= qq
D= 45
F= ss
G= 334
[id]=1234
A=
B= 2w
C=
D= 443
F=
G=
[id]=3434
A=
B= e3e
C=
D=
F= eww
G=
[id]=564
A= wsw
B=
C= sws
D= swsws
F=
G= dwd

I want to print this data into row like that


Code:
111      alpha  1    qq        45        ss                     334
1234            2w             443
3434            e3e                      ew
564      wsw         sws       swsws                            dwd

I mean first
1st row data in cursor postion 1
2nd row data in cursor postion 10
3rd row data in cursor postion 17
4th row data in cursor postion 22
5th row data in cursor postion 32
6th row data in cursor postion 42 etc



That will be great if someone can advice how to fix it.


Many thanks
# 2  
Old 07-15-2009
Code:
# awk -F= 'NR==1{printf $2;next}/id/{printf "\n%s",$2;next}{printf "\t%s",$2}' f3
111      alpha   1       qq      45      ss      334
1234             2w              443
3434             e3e                     eww
564      wsw             sws     swsws           dwd

From here you have to fix the print format.
# 3  
Old 07-15-2009
hello,

Many thanks for your reply, i have tested your code and the output look like the one you sent , but when i open with text editor the output is like below and not fix column and error when processing these data.


Code:
111     alpha     1         45         334
1234         2w         443        
3434         e3e             eww    
564     wsw         sws     swsws         dwd

any idea how to fix it and can you give idea for three attributes output with different cursor position (eg.%-9,%-16) like that

Code:
111      alpha           1
1234                     2w
3434                     e3e
564      wsw

Many thanks
# 4  
Old 07-16-2009
Quote:
Originally Posted by davidkhan
hbut when i open with text editor the output is like below
What text editor ? What OS? Smilie
# 5  
Old 07-16-2009
Code:
cat  a | paste - - - - - - - | sed 's/[^=   ]*=//g'

# 6  
Old 07-16-2009
Hello,
I am using microC text editor and using cygwin.

Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Comparing same column from two files, printing whole row with matching values

First I'd like to apologize if I opened a thread which is already open somewhere. I did a bit of searching but could quite find what I was looking for, so I will try to explaing what I need. I'm writing a script on our server, got to a point where I have two files with results. Example: File1... (6 Replies)
Discussion started by: mitabrev83
6 Replies

2. Shell Programming and Scripting

Print first row of column a, last row of column b if column a has the same value

I have a table with this structure: cola colb colc 1 19 lemon 20 31 lemon 32 100 lemon 159 205 cherries 210 500 cherries and need to parse it into this format: cola colb colc 1 100 lemon 159 500 cherries So I need the first row of cola and the last row of colb if colc has the... (3 Replies)
Discussion started by: coppuca
3 Replies

3. Shell Programming and Scripting

Print row on 4th column to all row

Dear All, I have input : SEG901 5173 9005 5740 SEG902 5227 5284 SEG903 5284 5346 SEG904 5346 9010 SEG905 5400 5456 SEG906 5456 5511 SEG907 5511 9011 SEG908 5572 9015 SEG909 5622 9020 SEG910 5678 5739 SEG911 5739 5796 SEG912 5796 9025 ... (3 Replies)
Discussion started by: attila
3 Replies

4. Shell Programming and Scripting

Print every 5 4th column values as separate row with different first column

Hi, I have the following file, chr1 100 200 20 chr1 201 300 22 chr1 220 345 23 chr1 230 456 33.5 chr1 243 567 90 chr1 345 600 20 chr1 430 619 21.78 chr1 870 910 112.3 chr1 914 920 12 chr1 930 999 13 My output would be peak1 20 22 23 33.5 90 peak2 20 21.78 112.3 12 13 Here the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

5. UNIX for Dummies Questions & Answers

awk to print first row with forth column and last row with fifth column in each file

file with this content awk 'NR==1 {print $4} && NR==2 {print $5}' file The error is shown with syntax error; what can be done (4 Replies)
Discussion started by: cdfd123
4 Replies

6. Shell Programming and Scripting

Change column to row base on column 2

Hi Guys, Input.txt L194 A -118.2 L194 B -115.1 L194 C -118.7 L196 A 0 L196 C 0 L197 A -111.2 L197 B -118.9 L197 C -119.9 L199 A -120.4 L199 B -119.9 ... (2 Replies)
Discussion started by: asavaliya
2 Replies

7. Shell Programming and Scripting

Subtracting each row from the first row in a single column file using awk

Hi Friends, I have a single column data like below. 1 2 3 4 5 I need the output like below. 0 1 2 3 4 where each row (including first row) subtracting from first row and the result should print below like the way shown in output file. Thanks Sid (11 Replies)
Discussion started by: ks_reddy
11 Replies

8. Shell Programming and Scripting

Moving data from a specified column/row to another column/row

Hello, I have an input file like the following: 11_3_4 2_1_35 3_15__ _16989 Where '_' is a space. The data is in a table. Is there a way for the program to prompt the user for x1,y1 and x2,y2, where x1,y1 is the desired number (for example x=6 y=4 is a value of 4) and move to a desired spot... (2 Replies)
Discussion started by: jl487
2 Replies

9. Shell Programming and Scripting

row to column and position data in to fixed column width

Dear friends, Below is my program and current output. I wish to have 3 or 4 column output in order to accomodate in single page. i do have subsequent command to process after user enter the number. Program COUNT=1 for MYDIR in `ls /` do VOBS=${MYDIR} echo "${COUNT}. ${MYDIR}" ... (4 Replies)
Discussion started by: baluchen
4 Replies

10. Shell Programming and Scripting

Changing the column for a row in a text file and adding another row

Hi, I want to write a shell script which increments a particular column in a row from a text file and then adds another row below the current row with the incremented value . For Eg . if the input file has a row : abc xyz lmn 89 lm nk o p I would like the script to create something like... (9 Replies)
Discussion started by: aYankeeFan
9 Replies
Login or Register to Ask a Question