↑ ↓ select, Enter open, Esc close

Compare two lists: what is missing from the second

Adjust the values, the command updates live
user@server
comm -23 <(sort -u all-domains.txt) <(sort -u backed-up-domains.txt)

Sorts both lists and, with -23, suppresses the columns for lines only in file 2 and for common lines. What remains is what appears exclusively in the first file. Use -13 for the opposite direction and -12 for only the common entries.

Note: comm requires sorted input, hence the process substitution with sort -u, which requires Bash. Trailing spaces cause lines that look identical to be treated as different.

Also searched as

  • difference between two lists linux
  • find lines in file a not in file b
  • compare two files line by line

Related one-liners

All in Text processing

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.