Performing set operations, such as union, intersection, and difference, is easy in linux using basic command line utilities like sort and comm (for compare).
Here is a cheat sheet for the basic set operations:
| Set Operation | Linux Equivalent |
|---|---|
A UNION B![]() |
sort -mu A B |
A INTERSECTION B![]() |
sort A B | uniq -d
-or- comm -12 A B* |
| A MINUS B |
comm -23 A B* |
* Both A and B need already be sorted.
Here is a more in depth article with some comments on performance and some alternative commands.


1 response so far ↓
HBoots // May 20, 2009 at 1:58 pm |
It doesn’t include Venn Diagrams, but this is what I was talking about last night: http://www.theplug.net/35/candytournament.htm Yea, Brackets!