comm - compare sorted files, line by line

1 minute read Published: 2022-04-20

comm is a command line tool that allows you to compare two sorted files, line by line.

By default, its output will be structured as a table with three columns:

Example:

$ cat file1
arduino_language_server
beancount
bicep
bsl_ls
ccls
clangd
clarity_lsp
clojure_lsp
codeqlls
crystalline

$ cat file2
angularls
ansiblels
arduino_language_server
asm_lsp
awk_ls
bashls
beancount
bicep
bsl_ls
ccls

$ comm file1 file2
        angularls
        ansiblels
                arduino_language_server
        asm_lsp
        awk_ls
        bashls
                beancount
                bicep
                bsl_ls
                ccls
clangd
clarity_lsp
clojure_lsp
codeqlls
crystalline

# -12 (similar to -1 -2) will suppress column 1 & 2
$ comm -12 file1 file2
arduino_language_server
beancount
bicep
bsl_ls
ccls