> -----Original Message-----
> From: Tucker, Ernie [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 10, 2002 11:51 AM
> To: '[EMAIL PROTECTED]'
> Subject: matching two files
> 
> 
> 
> Here is my first problem to the list. I have two different files with
> information that I need to find out what both have.
> ex.
> mac1.txt
> 0004.1112.3456
> 0003.45da.124d
> 
> mac2.txt
> 0004.1112.3456
> 0003.45da.124e
> 
> 
> need the output to show only the duplicates
> 
> 0004.1112.3456

I couldn't resist trying Perl Golf on this one...

perl -e 'do {$x{<>}=1} until eof; exists $x{$_} && print && delete $x{$_}
while(<>)' mac1.txt mac2.txt

The delete() is in there on the assumption you only want one instance
of each duplicate.

I'm sure this can be beat.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to