Re:Shell Magic: Set Operations with uniq
by markusbk on Wednesday May 30, 2018 @07:18AM
(#17186731)
If your input is already sorted (like this article assumes), you can use "sort -m", which is a lot faster. Also, to print only lines with duplicates, use "uniq -d" instead of "uniq -c | grep 2\ ".
Note the change of approach here: instead of making lines from b_list appear twice and grepping for that count, make lines from a_list appear twice and have uniq only print lines that aren't repeated.
Union: Instead of
do Intersection: Instead of do Relative complement: Instead of do Note the change of approach here: instead of making lines from b_list appear twice and grepping for that count, make lines from a_list appear twice and have uniq only print lines that aren't repeated.