找到多个文件之间的公共行

use*_*326 23 text-processing

我有 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
Run Code Online (Sandbox Code Playgroud)

所有文件都包含超过 2000 行并按第一列排序。

我想在所有文件中找到公共行。我试过 awk 和 grep 和 comm 但没有工作

Sté*_*las 29

由于文件已经排序:

comm -12 a b |
  comm -12 - c |
  comm -12 - d
Run Code Online (Sandbox Code Playgroud)


小智 6

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