[TriLUG] any idea how to do this?
Michael Rothwell
michael at rothwell.us
Fri Apr 20 17:19:20 EDT 2007
Perl!
#!/usr/bin/env perl
my %h;
foreach $filename (@ARGV) {
if ( open(F,$filename) ) {
while ($line=<F>) {
chomp $line;
$h{$line}++;
}
}
}
foreach $key (keys(%h)) {
if ($h{$key} == 1 ) {
print "$key\n";
}
}
On Apr 20, 2007, at 5:13 PM, jason wrote:
> say ive got 2 files with usernames or whatever in em
>
> file A has
>
> user1
> user2
> user3
>
> file B has
>
> user2
> user3
> user4
>
> and I want to strip out the duplicate entries from both files, i.e
> get output that in this case consists of
>
> user1
> user4
>
> ive looked at cmp,diff, uniq, but cant seem to find something
> thatll get this output.
>
> regards,
> Jason
>
> --
> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/
> trilug
> TriLUG Organizational FAQ : http://trilug.org/faq/
> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
More information about the TriLUG
mailing list