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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Remove duplicates from File from specific location gopikgunda Shell Programming and Scripting 1 04-08-2008 11:16 PM
Fastest way for searching the file vaibhavbhat UNIX for Advanced & Expert Users 3 03-10-2008 07:57 AM
How to remove duplicates without sorting orahi001 UNIX for Dummies Questions & Answers 4 01-17-2008 04:19 PM
how to delete/remove directory in fastest way getdpg Shell Programming and Scripting 6 03-07-2006 07:42 AM
fastest copy command vascobrito UNIX for Dummies Questions & Answers 0 07-20-2004 03:02 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #15  
Old 07-03-2005
Registered User
 

Join Date: Apr 2005
Posts: 51
Amit,

I tried sed '$!N; /^\(.*\)\n\1$/!P; D'
to remove duplicates. It didn't work:

ex:
file test1.txt has the following rows:
123
123
145
123
123

I used the following command to remove duplicates:
sort.sh test1.txt > test2.txt

sort.sh script has your sed command:
#!/bin/ksh
file1=$1
sed '$!N; /^\(.*\)\n\1$/!P; D' < $file1

Do you know for sure this sed command works? Or is there some thing that I am doing wrong. Because, result file test2.txt has the following rows: It didn't remove all the duplicates?

123
123
145
123

Appreciate any pointers.
Radhika.
Reply With Quote
Forum Sponsor
  #16  
Old 11-03-2005
Registered User
 

Join Date: Apr 2004
Location: Bangalore,India
Posts: 5
Why don't try to sort first & then take unique records.....
Is it not a good idea????
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 05:14 AM.


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