[YLUG] Subtracting one list from another.

Pete Jackson pmj109 at gmail.com
Sun Mar 25 13:05:22 BST 2007


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

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..........!!
> 




More information about the York mailing list