![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| removing duplicates based on key | pukars4u | Shell Programming and Scripting | 1 | 05-21-2008 04:50 PM |
| removing duplicates from a file | trichyselva | UNIX for Dummies Questions & Answers | 2 | 03-25-2008 10:49 AM |
| removing duplicates and sort -k | orahi001 | UNIX for Dummies Questions & Answers | 3 | 01-25-2008 09:59 AM |
| Removing duplicates [sort , uniq] | sharatz83 | Shell Programming and Scripting | 4 | 07-14-2006 06:12 PM |
| Removing duplicates | giannicello | Shell Programming and Scripting | 12 | 09-14-2005 07:12 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
removing duplicates
Hi I have a file that are a list of people & their credentials i recieve frequently The issue is that whne I catnet this list that duplicat entries exists & are NOT CONSECUTIVE (i.e. uniq -1 may not weork here )
I'm trying to write a scrip that will remove duplicate entries the script can typically made up of the following : -------------- Ms AA Unique to A More of A Mr BB Mr CC Ms AA Unique to A More of A Mr DD Mr EE Mr BB ------------ Some of my technqiues of just are't working quite right especially with ignoring white spaces (maybe sed here) (e.g. awk -F, '! mail[$3]++' inputfile ) any tips ? ts ms s |
|
||||
|
No worries
I've seen this forma ased manual somewhere... # delete duplicate, consecutive lines from a file (emulates "uniq"). # First line in a set of duplicate lines is kept, rest are deleted. sed '$!N; /^\(.*\)\n\1$/!P; D' # delete duplicate, nonconsecutive lines from a file. Beware not to # overflow the buffer size of the hold space, or else use GNU sed. sed -n 'G; s/\n/&&/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P' ALSO XXXXX '!($0 in a);{a[$0]=1}' logfile #where XXXX= awkfor Linuz & NAWK for Solaris |
![]() |
| Bookmarks |
| Tags |
| solaris |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|