The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-05-2008
stevie_velvet stevie_velvet is offline
Registered User
  
 

Join Date: Jan 2008
Location: London e Milano
Posts: 85
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
  #2 (permalink)  
Old 07-05-2008
stevie_velvet stevie_velvet is offline
Registered User
  
 

Join Date: Jan 2008
Location: London e Milano
Posts: 85
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
  #3 (permalink)  
Old 07-05-2008
stevie_velvet stevie_velvet is offline
Registered User
  
 

Join Date: Jan 2008
Location: London e Milano
Posts: 85
anyone know how to integrate ignoring blank lines in the above scripts ?
  #4 (permalink)  
Old 07-07-2008
stevie_velvet stevie_velvet is offline
Registered User
  
 

Join Date: Jan 2008
Location: London e Milano
Posts: 85
bump ;
Any clever SED / *AWK'rs out there who knows how to ignore blank lines & can integrate into the above examples.....?
  #5 (permalink)  
Old 07-07-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,311
Ignore blank lines:

Code:
sed 's/^$//g'
# or
grep -v ^$

  #6 (permalink)  
Old 07-07-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,926
Quote:
Originally Posted by stevie_velvet View Post
anyone know how to integrate ignoring blank lines in the above scripts ?
What is the expected output given your sample data?

Last edited by radoulov; 07-07-2008 at 10:28 AM..
Closed Thread

Bookmarks

Tags
solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:58 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0