The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Printing highest value from one column phil_heath UNIX for Dummies Questions & Answers 4 05-28-2009 06:39 AM
Printing 1st column to lower case using awk pinnacle Shell Programming and Scripting 11 05-18-2009 01:18 PM
Awk not printing the last combined column pinnacle Shell Programming and Scripting 5 05-08-2009 12:10 PM
printing in certain column based on some result kumar_amit Shell Programming and Scripting 6 12-12-2008 03:51 PM
Help with script printing column with space n3al10 Shell Programming and Scripting 4 12-16-2007 05:42 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-15-2009
davidkhan davidkhan is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 10
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 (permalink)  
Old 07-15-2009
danmero danmero is online now Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,449

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 (permalink)  
Old 07-15-2009
davidkhan davidkhan is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 10
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 (permalink)  
Old 07-16-2009
danmero danmero is online now Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,449
Quote:
Originally Posted by davidkhan View Post
hbut when i open with text editor the output is like below
What text editor ? What OS?
  #5 (permalink)  
Old 07-16-2009
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,099

Code:
cat  a | paste - - - - - - - | sed 's/[^=   ]*=//g'

  #6 (permalink)  
Old 07-16-2009
davidkhan davidkhan is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 10
Hello,
I am using microC text editor and using cygwin.

Thanks
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:06 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0