Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


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 !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-27-2012
Registered User
 
Join Date: Oct 2011
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Filtering the duplicates

Hello,

I want to filter all the duplicates of a record to one place. Sample input and output will give you better idea.

I am new to unix. Can some one help me on this?

Input:

Code:
7488	7389	chr1.fa	chr1.fa
3546	9887	chr5.fa	chr9.fa
7387	7898	chrX.fa	chr3.fa
7488	7389	chr1.fa	chr1.fa
7488	7389	chr21.fa	chr3.fa
7488	7389	chr1.fa	chr1.fa
9899	4577	chrX.fa	chrM.fa
3546	9887	chr5.fa	chr9.fa

My desired output:

Code:
7488	7389	chr1.fa	chr1.fa
7488	7389	chr1.fa	chr1.fa
7488	7389	chr1.fa	chr1.fa
3546	9887	chr5.fa	chr9.fa
3546	9887	chr5.fa	chr9.fa
7387	7898	chrX.fa	chr3.fa
7488	7389	chr21.fa	chr3.fa
9899	4577	chrX.fa	chrM.fa

Thanks in advance,


Moderator's Comments:
Please view this code tag video for how to use code tags when posting code and data.

Last edited by vbe; 06-27-2012 at 11:30 AM.. Reason: code tags please
Sponsored Links
    #2  
Old 06-27-2012
Registered User
 
Join Date: Jan 2012
Posts: 267
Thanks: 222
Thanked 4 Times in 4 Posts

Code:
cat input | sort -k3,3

Sponsored Links
    #3  
Old 06-27-2012
ctsgnb ctsgnb is offline Forum Advisor  
Registered User
 
Join Date: Oct 2010
Location: France
Posts: 2,763
Thanks: 72
Thanked 587 Times in 561 Posts

Code:
sort <input

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Duplicates in an XML file TasosARISFC Shell Programming and Scripting 5 09-12-2011 03:51 PM
Duplicates venkatesht UNIX for Dummies Questions & Answers 3 08-10-2010 08:02 AM
Non Duplicates awk_beginner Shell Programming and Scripting 3 02-27-2009 08:50 AM
getting duplicates megh HP-UX 4 09-14-2008 01:09 AM
lastlog has duplicates chlawren AIX 1 06-19-2006 04:30 AM



All times are GMT -4. The time now is 08:34 PM.