Wednesday, November 4, 2009

Set operations on the unix shell

Some commands to apply set operations to files...

Union:

sort set1 set2 | uniq > lines_in_set1_OR_set2

Intersection:

sort set1 set2 | uniq -d > lines_in_set1_AND_set2

Difference:

comm -23 set1 set2 > lines_in_set1_BUT_NOT_in_set2

Autor: David Leuschner