[YLUG] Subtracting one list from another.

Gaffer derrick_s at tesco.net
Sun Mar 25 13:49:01 BST 2007


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..........!!
>
> _______________________________________________
> York mailing list
> York at lists.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/york

-- 
Best Regards:
             Derrick.



More information about the York mailing list