combine
combine lines of two files using boolean operations
TLDR
SYNOPSIS
combine file1 and|not|or|xor file2
DESCRIPTION
combine performs boolean set operations on the lines of two files, treating each file as a set of lines. Input does not need to be sorted; output lines appear in the order they occur in file1 (with file2 lines appended for or).The command is part of the moreutils collection of handy Unix utilities and is useful for quickly computing set relationships on plain text data without piping through sort, uniq, and comm.
PARAMETERS
and
Output lines in file1 that are also in file2 (intersection).not
Output lines in file1 that are not in file2 (set difference).or
Output lines in file1 or in file2 (union); file2 lines are appended.xor
Output lines in exactly one of file1 or file2 (symmetric difference).file1, file2
Input files. Use - to read from standard input.
CAVEATS
The operations are not commutative: swapping file1 and file2 can change the output order. Duplicate lines within a file are preserved in the output; pipe through sort -u for symmetric, deduplicated results. On some distributions the binary is installed as combine from moreutils, but may conflict with ImageMagick's legacy combine tool - check which combine or use the package's full path.
HISTORY
combine is part of moreutils, a collection of Unix utilities maintained by Joey Hess since around 2006. It provides set-theoretic operations that would otherwise require multiple pipeline stages with sort and comm.
