2 ms·
Never knew that one can do set operations using sort and uniq. For example, a and b are text files that are already unique. Note this is fast, and works on fil
by yarapavan 16y ago
Never knew that one can do set operations using sort and uniq.
For example, a and b are text files that are already unique. Note this is fast, and works on files of arbitrary size, up to many gigabytes. (Sort is not limited by memory, though you may need to use -T if you have a small root partition.)
cat a b | sort | uniq > c # c is a union b
cat a b | sort | uniq -d > c # c is a intersection b
cat a b b | sort | uniq -u > c # c is set difference a - b