shellで集合演算

シェルで集合演算をやりたかった。でもあまり自信がなかったのでいつもRの%in%で済ませていた。以下のようにしてできるらしい。
論理和
cat a b | sort | uniq
論理積
cat a b | sort | uniq -d
排他的論理和
cat a b | sort | uniq -u
差集合(A-B)
(cat a b | sort | uniq -u; cat b) | sort | uniq -d
差集合(B-A)
(cat a b | sort | uniq -u; cat a) | sort | uniq -d

コメント

このブログの人気の投稿

Inverse-normal transformation

SKAT

locuszoom