查找多个文件之间的共同点


20

我有4个文件,就像

       file A
       >TCONS_00000867
       >TCONS_00001442
       >TCONS_00001447
       >TCONS_00001528
       >TCONS_00001529
       >TCONS_00001668
       >TCONS_00001921

       file b
       >TCONS_00001528
       >TCONS_00001529
       >TCONS_00001668
       >TCONS_00001921
       >TCONS_00001922
       >TCONS_00001924

       file c
       >TCONS_00001529
       >TCONS_00001668
       >TCONS_00001921
       >TCONS_00001922
       >TCONS_00001924
       >TCONS_00001956
       >TCONS_00002048

       file d
       >TCONS_00001922
       >TCONS_00001924
       >TCONS_00001956
       >TCONS_00002048

所有文件包含2000行以上,并按第一列排序。

我想在所有文件中找到共同的地方。我尝试了awk,grep和comm,但是没有用

Answers:



3
cat a b c d |sort |uniq -c |sed -n -e 's/^ *4 \(.*\)/\1/p'

实际上,保存sed,这是发现在许多文件重复的行相当不错:catsortuniq -c。不知何故我没有想到这个,好的答案!
smaslennikov

您还可以使用uniq命令仅打印重复的行:uniq -cd
mems
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.