The UNIX and Linux Forums  

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


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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
finding duplicates in columns and removing lines totus Shell Programming and Scripting 17 2 Days Ago 08:27 AM
Help removing lines with duplicated columns yahyaaa Shell Programming and Scripting 14 05-17-2008 04:33 AM
Remove lines, Sorted with Time based columns using AWK & SORT karthikn7974 Shell Programming and Scripting 1 05-09-2008 08:04 PM
sorting file content on columns marshmallow UNIX for Dummies Questions & Answers 2 01-04-2007 09:10 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-08-2007
Registered User
 

Join Date: Nov 2007
Posts: 4
Lightbulb Removing lines that are (same in content) based on columns

I have a file which looks like

AA BB CC DD EE FF GG HH KK
AA BB GG HH KK FF CC DD EE
AA BB CC DD EE UU VV XX ZZ
AA BB VV XX ZZ UU CC DD EE

....
I want the script to give me only one line based on duplicate contents:

AA BB CC DD EE FF GG HH KK
AA BB CC DD EE UU VV XX ZZ
Reply With Quote
Forum Sponsor
  #2  
Old 11-08-2007
Smiling Dragon's Avatar
Disorganised User
 
Join Date: Nov 2007
Location: New Zealand
Posts: 734
Call me stupid but I don't follow what you are after here... the out put example you've given has two lines but you seem to be asking for one line? Please elaborate on what you are after
Reply With Quote
  #3  
Old 11-09-2007
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milano, Italia/Варна, България
Posts: 1,907
I suppose he wahts something like this,
but for more general solution it would be
better if we have more sample data:

Code:
awk '{x[$3v$4v$5v$7v$8v$9]}
!($7v$8v$9v$3v$4v$5 in x)' v=" " filename
Use nawk or /usr/xpg4/bin/awk on Solaris.
Reply With Quote
  #4  
Old 11-09-2007
Registered User
 

Join Date: Nov 2007
Posts: 4
As a clarification:
I am looking for one line per duplicate info. Therefore, the 4 lines input file (given as an example) is formed of two blocks, 2 lines each, containaing duplicate data. Thus the result is two lines.

AA BB CC DD EE FF GG HH KK ----- First Block
AA BB GG HH KK FF CC DD EE ----- First Block

AA BB CC DD EE UU VV XX ZZ ----- Second Block
AA BB VV XX ZZ UU CC DD EE ----- Second Blcok


The results should be like the following:
AA BB CC DD EE FF GG HH KK ----- Result for First Block

AA BB CC DD EE UU VV XX ZZ ----- Result for Second Block

I hope it is clear now!
Reply With Quote
  #5  
Old 11-09-2007
Registered User
 

Join Date: Nov 2007
Posts: 4
Quote:
Originally Posted by radoulov View Post
I suppose he wahts something like this,
but for more general solution it would be
better if we have more sample data:

Code:
awk '{x[$3v$4v$5v$7v$8v$9]}
!($7v$8v$9v$3v$4v$5 in x)' v=" " filename
Use nawk or /usr/xpg4/bin/awk on Solaris.
Radoulov,
Your script did not work with me! (awk error)
Reply With Quote
  #6  
Old 11-09-2007
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milano, Italia/Варна, България
Posts: 1,907
Quote:
Originally Posted by adsforall View Post
Radoulov,
Your script did not work with me! (awk error)
Hm,
and you're not on Solaris?
Reply With Quote
  #7  
Old 11-09-2007
Registered User
 

Join Date: Nov 2007
Posts: 4
Quote:
Originally Posted by radoulov View Post
Hm,
and you're not on Solaris?
I am using Solaris 9
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 09:23 PM.


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