by markusbk · 8y ago · 0 comments
Union: Instead of
cat a_list b_list | sort | uniq
do sort -m a_list b_list | uniq
Intersection: Instead of cat a_list b_list | sort | uniq -c | grep 2\
do sort -m a_list b_list | uniq -d
Relative complement: Instead of cat a_list b_list b_list | sort | uniq -c | grep 2\
do sort -m a_list a_list b_list | uniq -u
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.No comments yet.