|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Merge rows with common column
Dear all I have big file with two columns Code:
A_AA960715 GO:0006952
A_AA960715 GO:0008152
A_AA960715 GO:0016491
A_AA960715 GO:0007165
A_AA960715 GO:0005618
A_AA960716 GO:0006952
A_AA960716 GO:0005618
A_AA960716 GO:0055114
A_AA960716 GO:0032440
A_AA960716 GO:0016023
A_AA960716 GO:0016310and I need to have output file Code:
A_AA960715 GO:0006952 GO:0008152 GO:0016491 GO:0007165 GO:0005618
A_AA960716 GO:0006952 GO:0005618 GO:0055114 GO:0032440 GO:0016023 GO:0016310 GO:0016301 GO:0007165I already tried the commands given by Otheus but it didn't work for me, please help me urgently Regards Last edited by Scott; 02-20-2012 at 08:29 AM.. Reason: Code tags |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
we have one file and what about the othere file to take the common column and additional column to merge ?
we have two files right ? Cheers, Ranga ![]() |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Dear Ranga, this is one text file with two columns Code:
A_AA960715 GO:0006952
A_AA960715 GO:0008152
A_AA960715 GO:0016491
A_AA960715 GO:0007165and I need to have new file with two columns where all the values corresponding to one value must be in row and in first column there must not the repetition of value, like this Code:
A_AA960715 GO:0006952 GO:0008152 GO:0016491 GO:0007165 GO:0005618 I think you its clear now thanks Last edited by Scott; 02-20-2012 at 08:30 AM.. Reason: Code tags |
|
#4
|
||||
|
||||
|
Code:
awk '{a[$1]=a[$1]" "$2}END{for (i in a) print i" "a[i]}' file |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Thanks Bartus, but I got this error Code:
$ awk '{a[$1]=a[$1]" "$2}END{for (i in a) print i" "a[i]}' file
awk: fatal: cannot open file `file' for reading (No such file or directory)actually I am new to these commands, please help me regards Last edited by Scott; 02-20-2012 at 08:30 AM.. Reason: Please use code tags |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
"file" is the filename of the big file... I don't know what it is in your case...
|
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
yes I gave the name of file GO.txt it was, but the error was that ,
please tell me what to do then,, thanks |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Writing a loop to merge multiple files by common column | evelibertine | UNIX for Dummies Questions & Answers | 1 | 10-07-2011 11:20 AM |
| merge two text files of different size on common index | LMHmedchem | Shell Programming and Scripting | 8 | 05-01-2011 08:45 PM |
| "Join" or "Merge" more than 2 files into single output based on common key (column) | Katabatic | Shell Programming and Scripting | 1 | 05-20-2010 11:41 AM |
| merge rows based on a common column | smriti_shridhar | Shell Programming and Scripting | 6 | 10-17-2008 06:15 AM |
| merge based on common, awk help | jkl_jkl | Shell Programming and Scripting | 3 | 03-17-2008 07:13 AM |
|
|