[Novalug] Finding similarities in files
Ken Kauffman
kkauffman at headfog.com
Fri Sep 5 15:47:19 EDT 2008
sort + diff?
K
On Fri, Sep 5, 2008 at 15:26, Jon LaBadie <novalugml at jgcomp.com> wrote:
> On Fri, Sep 05, 2008 at 12:46:12PM -0400, James Ewing Cottrell 3rd wrote:
> > man comm
> >
> > Great command. Ancient. Learn it!
> >
> > JIM
> >
> > Jon Taimanglo wrote:
> > > I know this is probably an easy one, but I have 2 files of IP's. I
> > > want to find which IP's are in both files and print that out to
> > > another file. Anyone have any ideas?
> > >
>
> comm will not be a good choice here as it compares by
> collating sequence, not numeric. So all IP octets
> would have to be the same length for comm to work
> as desired.
>
> Another alternative
>
> sort -n f1 f2 | uniq -d
>
> You may have to check if the sort works properly without
> specifying fields. If not you may need a sort like
>
> sort -t. -k 1,1 -k 2,2 -k 3,3 -k 4,4 f1 f2 | uniq -d
>
> Jon
> --
> Jon H. LaBadie jon at jgcomp.com
> JG Computing
> 12027 Creekbend Drive (703) 787-0884
> Reston, VA 20194 (703) 787-0922 (fax)
> _______________________________________________
> Novalug mailing list
> Novalug at calypso.tux.org
> http://calypso.tux.org/cgi-bin/mailman/listinfo/novalug
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://calypso.tux.org/pipermail/novalug/attachments/20080905/3eb63b80/attachment.html
More information about the Novalug
mailing list