[YLUG] Subtracting one list from another.
Gaffer
derrick_s at tesco.net
Sun Mar 25 14:18:20 BST 2007
Hi Richard,
On Sunday 25 March 2007 14:08, Richard Birnie inscribed thus:
> Hi,
>
> If you know any Perl at all then there's a module on CPAN that is
> designed for exactly this task. Take a look at this
> http://search.cpan.org/~jkeenan/List-Compare-0.33/lib/List/Compare/
>Functional.pm The get_unique or get_complement functions are
> probably what you want.
>
> I'm sure there'll be a lot of people going 'yuck, perl' at this
> point. To those people I say: meh. :-)
>
> Rich
No ! I am not familiar with perl, but I have an open mind. So I will
go and have a look and see !!
I obviously don't understand "diff" and the man pages are a bit
terse !
Thankyou for your input.
> On Sunday 25 March 2007 13:48:44 Gaffer wrote:
> > Thankyou Pete,
> >
> > On Sunday 25 March 2007 13:05, Pete Jackson inscribed thus:
> > > Hi,
> > >
> > > I think something like "cat g1.txt g2.txt | sort | uniq -u"
> > > will give you all items that appear in exactly one of the lists
> > > (the '-u' flag means print only unique lines). You'd need to
> > > make sure each item appeared at most once in each source list
> > > for this to work.
> > >
> > > Hope that helps, and I've not misunderstood the problem,
> > >
> > > Pete
> >
> > I tried something similar to this but end up with a file that
> > contains everything in both files but not the files that occur in
> > one but not the other. Since these are both text files "file one
> > + file two | sort -u" gives me the same result !
> >
> > Where I am trying to get to, is a file that only contains the
> > difference. Which is what I thought "diff" was supposed to do !
> >
> > > Gaffer wrote:
> > > > Hi Guys,
> > > >
> > > > How can I subtract items from two lists where one list has
> > > > items that are not in the other list in order to get a list
> > > > of those items ?
> > > >
> > > > Sorry if that sounds confusing !
> > > >
> > > > I have tried "diff -a g1.txt g2.txt > g3.txt" but I end up
> > > > with a file that is as big as the sum of the g1 + g2 file
> > > > sizes and seems to have as entries that are not in either
> > > > file.
> > > >
> > > > cmp just says the first line is different and stops.
> > > >
> > > > I'm obviously doing something wrong..........!!
--
Best Regards:
Derrick.
More information about the York
mailing list