Help with duplicate column 1 data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with duplicate column 1 data
# 1  
Old 09-10-2012
Help with duplicate column 1 data

Input file
Code:
Q6GZV8  AY548484>AAT09676.1>YP_031595.1>2947737>CLSP2512393
P0C9E9  AY261366
P0C9K3  AY261361>IPR004848>PF01639
P0C9I4  AY261363>IPR004848

Desired output file
Code:
Q6GZV8  AY548484
Q6GZV8  AAT09676.1
Q6GZV8  YP_031595.1
Q6GZV8  2947737
Q6GZV8  CLSP2512393
P0C9E9  AY261366
P0C9K3  AY261361
P0C9K3  IPR004848
P0C9K3  PF01639
P0C9I4  AY261363
P0C9I4  IPR004848

">" is worked as separator in column 2.
Just hope that column 1 data will duplicate for each element that separator by ">" in column 2 into a new line.

Thanks
# 2  
Old 09-10-2012
Code:
awk -F'[ \t>]*' '{for(i=2;i<=NF;i++) print $1,$i}' file

This User Gave Thanks to elixir_sinari For This Post:
# 3  
Old 09-10-2012
Code:
awk -F "[> ]" '{ for (i=2;i<=NF;i++) {if($i !=""){ print $1,$i }}}' file

This User Gave Thanks to pamu For This Post:
# 4  
Old 09-10-2012
Code:
awk '{gsub(/>/,RS $1 FS)}1' infile

These 2 Users Gave Thanks to complex.invoke For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Duplicate and change a column

Hi, I have a file with list of items: a b c I would like to run a 1-liner (awk/perl) to duplicate and change the value of the existing column, i.e.: a a b b c c I can duplicate with awk: awk '{print $1 " " $1 }' but couldn't figure out how to do the character change, your help is... (5 Replies)
Discussion started by: yan1
5 Replies

2. Shell Programming and Scripting

Find duplicate values in specific column and delete all the duplicate values

Dear folks I have a map file of around 54K lines and some of the values in the second column have the same value and I want to find them and delete all of the same values. I looked over duplicate commands but my case is not to keep one of the duplicate values. I want to remove all of the same... (4 Replies)
Discussion started by: sajmar
4 Replies

3. Shell Programming and Scripting

Change data in one column with data from another file's column

Hello, I have this file outputData: # cat /tmp/outputData __Capacity^6^NBSC01_Licences^L3_functionality_for_ESB_switch __Capacity^2100^NBSC01_Licences^Gb_over_IP __Capacity^1837^NBSC01_Licences^EDGE_BSS_Fnc __Capacity^1816^NBSC01_Licences^GPRS_CS3_and_CS4... (1 Reply)
Discussion started by: nypreH
1 Replies

4. Shell Programming and Scripting

awk to sum a column based on duplicate strings in another column and show split totals

Hi, I have a similar input format- A_1 2 B_0 4 A_1 1 B_2 5 A_4 1 and looking to print in this output format with headers. can you suggest in awk?awk because i am doing some pattern matching from parent file to print column 1 of my input using awk already.Thanks! letter number_of_letters... (5 Replies)
Discussion started by: prashob123
5 Replies

5. Shell Programming and Scripting

Duplicate third column to every line

Dear All, I have file input like this: INP901 5173 4114 INP902 5227 INP903 5284 INP904 5346 INP905 5400 INP906 5456 INP907 5511 INP908 5572 INP909 5622 INP910 5678 INP911 5739 INP912 5796 INP913 5845 INP914 5910 INP915 5965 (2 Replies)
Discussion started by: attila
2 Replies

6. Shell Programming and Scripting

Compare 2 files and match column data and align data from 3 column

Hello experts, Please help me in achieving this in an easier way possible. I have 2 csv files with following data: File1 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:36:09,JOB_5340 08/23/2012 12:36:14,JOB_5340 08/23/2012 12:36:22,JOB_5350 08/23/2012... (5 Replies)
Discussion started by: asnandhakumar
5 Replies

7. UNIX for Dummies Questions & Answers

awk: duplicate a column into a new one

Hi ! I have a "|" delimited file: field 1|field2|field3|field4 AAA|BBB|CCC|DDD EEE|FFF|GGG|HHH Using awk, I need to duplicate the 2nd column and print it into a 5th new column, like that: output: field 1|field2|field3|field4|field 2 AAA|BBB|CCC|DDD|BBB EEE|FFF|GGG|HHH|FFF Thanks... (1 Reply)
Discussion started by: lucasvs
1 Replies

8. Shell Programming and Scripting

Delete duplicate data and pertain the latest month data.

Hi I have a file with following records It contains three months of data, some data is duplicated,i need to access the latest data from the duplicate ones. for e.g; i have foll data "200","0","","11722","-63","","","","11722","JUL","09" "200","0","","11722","-63","","","","11722","JUL","09"... (10 Replies)
Discussion started by: vee_789
10 Replies

9. Shell Programming and Scripting

Remove duplicate line detail based on column one data

My input file: AVI.out <detail>named as the RRM .</detail> AVI.out <detail>Contains 1 RRM .</detail> AR0.out <detail>named as the tellurite-resistance.</detail> AWG.out <detail>Contains 2 HTH .</detail> ADV.out <detail>named as the DENR family.</detail> ADV.out ... (10 Replies)
Discussion started by: patrick87
10 Replies

10. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies
Login or Register to Ask a Question