Sponsored Content
Operating Systems Solaris How to remove duplicate records with out sort Post 302171291 by svenkatareddy on Thursday 28th of February 2008 05:09:19 AM
Old 02-28-2008
How to remove duplicate records with out sort

Can any one give me command How to delete duplicate records with out sort.

Suppose if the records like below:

345,bcd,789
123,abc,456
234,abc,456
712,bcd,789

out tput should be
345,bcd,789
123,abc,456

Key for the records is 2nd and 3rd fields.fields are seperated by colon(,).
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove all instances of duplicate records from the file

Hi experts, I am new to scripting. I have a requirement as below. File1: A|123|NAME1 A|123|NAME2 B|123|NAME3 File2: C|123|NAME4 C|123|NAME5 D|123|NAME6 1) I have 2 merge both the files. 2) need to do a sort ( key fields are first and second field) 3) remove all the instances... (3 Replies)
Discussion started by: vukkusila
3 Replies

2. Shell Programming and Scripting

How to remove duplicate records with out sort

Can any one give me command How to delete duplicate records with out sort. Suppose if the records like below: 345,bcd,789 123,abc,456 234,abc,456 712,bcd,789 out tput should be 345,bcd,789 123,abc,456 Key for the records is 2nd and 3rd fields.fields are seperated by colon(,). (19 Replies)
Discussion started by: svenkatareddy
19 Replies

3. Shell Programming and Scripting

Remove duplicate records

I want to remove the records based on duplicate. I want to remove if two or more records exists with combination fields. Those records should not come once also file abc.txt ABC;123;XYB;HELLO; ABC;123;HKL;HELLO; CDE;123;LLKJ;HELLO; ABC;123;LSDK;HELLO; CDF;344;SLK;TEST key fields are... (7 Replies)
Discussion started by: svenkatareddy
7 Replies

4. Shell Programming and Scripting

Remove Duplicate Records

Hi frinds, Need your help. item , color ,desc ==== ======= ==== 1,red ,abc 1,red , a b c 2,blue,x 3,black,y 4,brown,xv 4,brown,x v 4,brown, x v I have to elemnet the duplicate rows on the basis of item. the final out put will be 1,red ,abc (6 Replies)
Discussion started by: imipsita.rath
6 Replies

5. Shell Programming and Scripting

Sort and Remove Duplicate on file

How do we sort and remove duplicate on column 1,2 retaining the record with maximum date (in feild 3) for the file with following format. aaa|1234|2010-12-31 aaa|1234|2010-11-10 bbb|345|2011-01-01 ccc|346|2011-02-01 bbb|345|2011-03-10 aaa|1234|2010-01-01 Required Output ... (5 Replies)
Discussion started by: mabarif16
5 Replies

6. Shell Programming and Scripting

Remove somewhat Duplicate records from a flat file

I have a flat file that contains records similar to the following two lines; 1984/11/08 7 700000 123456789 2 1984/11/08 1941/05/19 7 700000 123456789 2 The 123456789 2 represents an account number, this is how I identify the duplicate record. The ### signs represent... (4 Replies)
Discussion started by: jolney
4 Replies

7. Shell Programming and Scripting

Remove duplicate lines based on field and sort

I have a csv file that I would like to remove duplicate lines based on field 1 and sort. I don't care about any of the other fields but I still wanna keep there data intact. I was thinking I could do something like this but I have no idea how to print the full line with this. Please show any method... (8 Replies)
Discussion started by: cokedude
8 Replies

8. Shell Programming and Scripting

Remove duplicate chars and sort string [SED]

Hi, INPUT: DCBADD OUTPUT: ABCD The SED script should alphabetically sort the chars in the string and remove the duplicate chars. (5 Replies)
Discussion started by: jds93
5 Replies

9. Shell Programming and Scripting

Remove duplicate records

Hi, i am working on a script that would remove records or lines in a flat file. The only difference in the file is the "NOT NULL" word. Please see below example of the input file. INPUT FILE:> CREATE a ( TRIAL_CLIENT NOT NULL VARCHAR2(60), TRIAL_FUND NOT NULL... (3 Replies)
Discussion started by: reignangel2003
3 Replies

10. Shell Programming and Scripting

Remove duplicate lines, sort it and save it as file itself

Hi, all I have a csv file that I would like to remove duplicate lines based on 1st field and sort them by the 1st field. If there are more than 1 line which is same on the 1st field, I want to keep the first line of them and remove the rest. I think I have to use uniq or something, but I still... (8 Replies)
Discussion started by: refrain
8 Replies
Hash::AsObject(3pm)					User Contributed Perl Documentation				       Hash::AsObject(3pm)

NAME
Hash::AsObject - treat hashes as objects, with arbitrary accessors/mutators SYNOPSIS
$h = Hash::AsObject->new; $h->foo(123); print $h->foo; # prints 123 print $h->{'foo'}; # prints 123 $h->{'bar'}{'baz'} = 456; print $h->bar->baz; # prints 456 DESCRIPTION
A Hash::AsObject is a blessed hash that provides read-write access to its elements using accessors. (Actually, they're both accessors and mutators.) It's designed to act as much like a plain hash as possible; this means, for example, that you can use methods like "DESTROY" to get or set hash elements with that name. See below for more information. METHODS
The whole point of this module is to provide arbitrary methods. For the most part, these are defined at runtime by a specially written "AUTOLOAD" function. In order to behave properly in all cases, however, a number of special methods and functions must be supported. Some of these are defined while others are simply emulated in AUTOLOAD. new $h = Hash::AsObject->new; $h = Hash::AsObject->new(\%some_hash); $h = Hash::AsObject->new(%some_other_hash); Create a new Hash::AsObject. If called as an instance method, this accesses a hash element 'new': $h->{'new'} = 123; $h->new; # 123 $h->new(456); # 456 isa This method cannot be used to access a hash element 'isa', because Hash::AsObject doesn't attempt to handle it specially. can Similarly, this can't be used to access a hash element 'can'. AUTOLOAD $h->{'AUTOLOAD'} = 'abc'; $h->AUTOLOAD; # 'abc' $h->AUTOLOAD('xyz') # 'xyz' Hash::AsObject::AUTOLOAD recognizes when AUTOLOAD is begin called as an instance method, and treats this as an attempt to get or set the 'AUTOLOAD' hash element. DESTROY $h->{'DESTROY'} = []; $h->DESTROY; # [] $h->DESTROY({}) # {} "DESTROY" is called automatically by the Perl runtime when an object goes out of scope. A Hash::AsObject can't distinguish this from a call to access the element $h->{'DESTROY'}, and so it blithely gets (or sets) the hash's 'DESTROY' element; this isn't a problem, since the Perl interpreter discards any value that DESTROY returns when called automatically. VERSION When called as a class method, this returns $Hash::AsObject::VERSION; when called as an instance method, it gets or sets the hash element 'VERSION'; import Since Hash::AsObject doesn't export any symbols, this method has no special significance and you can safely call it as a method to get or set an 'import' element. When called as a class method, nothing happens. The methods "can()" and "isa()" are special, because they're defined in the "UNIVERSAL" class that all packages automatically inherit from. Unfortunately, this means that you can't use Hash::AsObject to access elements 'can' and 'isa'. CAVEATS
No distinction is made between non-existent elements and those that are present but undefined. Furthermore, there's no way to delete an element without resorting to "delete $h->{'foo'}". Storing a hash directly into an element of a Hash::AsObject instance has the effect of blessing that hash into Hash::AsObject. For example, the following code: my $h = Hash::AsObject->new; my $foo = { 'bar' => 1, 'baz' => 2 }; print ref($foo), " "; $h->foo($foo); print ref($foo), " "; Produces the following output: HASH Hash::AsObject I could fix this, but then code like the following would throw an exception, because "$h->foo($foo)" will return a plain hash reference, not an object: $h->foo($foo)->bar; Well, I can make "$h->foo($foo)->bar" work, but then code like this won't have the desired effect: my $foo = { 'bar' => 123 }; $h->foo($foo); $h->foo->bar(456); print $foo->{'bar'}; # prints 123 print $h->foo->bar; # prints 456 I suppose I could fix that, but that's an awful lot of work for little apparent benefit. Let me know if you have any thoughts on this. BUGS
Autovivification is probably not emulated correctly. The blessing of hashes stored in a Hash::AsObject might be considered a bug. Or a feature; it depends on your point of view. TO DO
o Add the capability to delete elements, perhaps like this: use Hash::AsObject 'deleter' => 'kill'; $h = Hash::AsObject->new({'one' => 1, 'two' => 2}); kill $h, 'one'; That might seem to violate the prohibition against exporting functions from object-oriented packages, but then technically it wouldn't be exporting it from anywhere since the function would be constructed by hand. Alternatively, it could work like this: use Hash::AsObject 'deleter' => 'kill'; $h = Hash::AsObject->new({'one' => 1, 'two' => 2}); $h->kill('one'); But, again, what if the hash contained an element named 'kill'? o Define multiple classes in "Hash/AsObject.pm"? For example, there could be one package for read-only access to a hash, one for hashes that throw exceptions when accessors for non-existent keys are called, etc. But this is hard to do fully without (a) altering the underlying hash, or (b) defining methods besides AUTOLOAD. Hmmm... VERSION
0.06 AUTHOR
Paul Hoffman <nkuitse AT cpan DOT org> CREDITS
Andy Wardley for Template::Stash, which was my inspiration. Writing template code like this: [% foo.bar.baz(qux) %] Made me yearn to write Perl code like this: foo->bar->baz($qux); COPYRIGHT
Copyright 2003-2007 Paul M. Hoffman. All rights reserved. This program is free software; you can redistribute it and modify it under the same terms as Perl itself. perl v5.10.1 2010-04-24 Hash::AsObject(3pm)
All times are GMT -4. The time now is 11:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy