comm

Select or reject lines common to two files. Both files must be sorted. More information: https://www.gnu.org/software/coreutils/comm.

comm file1 file2

comm -12 file1 file2

cat file1 | comm -12 - file2

comm -23 file1 file2 > file1_only

comm -13 <(sort file1) <(sort file2)