[YLUG] Subtracting one list from another.

Gaffer derrick_s at tesco.net
Sun Mar 25 16:37:41 BST 2007


Hi Richard,

On Sunday 25 March 2007 15:41, Richard G. Clegg inscribed thus:
> Pete Jackson wrote:
> > 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.
>
> cat g1.txt | sort | uniq | cat g2.txt g2.txt - | sort | uniq -u
>
> will print one copy of any line which appears only in g1.txt.
> Note that it might stumble over whitespace -- the line a with a
> space following is different from the same line without.

Thanks for the clues Richard.

-- 
Best Regards:
             Derrick.



More information about the York mailing list