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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
More than transposing! bulash UNIX Desktop for Dummies Questions & Answers 3 04-11-2008 02:20 PM
Transposing string unibboy Shell Programming and Scripting 3 02-13-2008 03:12 PM
Major Awk problems (Searching, If statements, transposing etc.) Blivo Shell Programming and Scripting 2 09-05-2007 03:41 AM
Another transposing issue stevesmith Shell Programming and Scripting 14 09-16-2006 01:48 AM
transposing letters myscsa2004 Shell Programming and Scripting 4 05-12-2004 07:11 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 07-29-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
Quote:
Originally Posted by mskcc
Wired, My file is a multi-column based tab delimited file with uneven rows. It needs to be transposed to row based txt file. This is code,
bash-2.03$ more file_transpose
###file transpose, colume to row
###from unix.com/ygor, 07/29/2005

awk '{
for (f = 1; f <= NF; f++)
a[NR, f] = $f
}
NF > nf { nf = NF }
END {
for (f = 1; f <= nf; f++)
for (r = 1; r <= NR; r++)
printf a[r, f] (r==NR ? RS : FS)
}' atcc_fidler_pvs_all_markers.txt > atcc_fidler_pvs_all_markers_out.txt

The error message is,
sorgerlab-x% bash
bash-2.03$ ./file_transpose
awk: syntax error near line 3
awk: illegal statement near line 3
awk: syntax error near line 9
awk: illegal statement near line 9

Thanks for the help
If on Solaris, try using 'nawk' instead of plain 'awk'
Reply With Quote
Forum Sponsor
  #9  
Old 07-29-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
Quote:
Originally Posted by mskcc
by the way, how to search the archives here.
by clicking the 'Search' and filling in the drop-down menu.
Reply With Quote
  #10  
Old 07-29-2005
Registered User
 

Join Date: Jul 2005
Posts: 137
Using Ruby:

[[1,2,3], [4,5,6]].transpose

yields

[[1, 4], [2, 5], [3, 6]]
Reply With Quote
  #11  
Old 08-03-2005
Registered User
 

Join Date: Jul 2005
Posts: 37
Thank you guys. It worked by change awk to nawk, but the output is not tab delimited format. Can anyone fix it for me? thx.
Reply With Quote
  #12  
Old 08-03-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
nawk -v OFS='\t' ..........
Reply With Quote
  #13  
Old 08-03-2005
Registered User
 

Join Date: Jul 2005
Posts: 37
Thanks! It worked well. But if I need to transpose a file like this to a colume based file, how can I do it? Please help. Thanks in advance.
Reply With Quote
  #14  
Old 08-03-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
can you elaborate on the question, pls?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:09 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0