Files and folders

Compare two files and see what changed

Show the lines that differ between two files or just check whether they're the same.

Fill these in once
  1. Show what changed
    Terminal
    diff -u old.txt new.txt

    Lines starting with - are only in the first file. Lines starting with + are only in the second.

  2. Just check whether they differ
    Terminal
    diff -q old.txt new.txt

    No output means they're the same.

  3. See it side by side
    Terminal
    diff -y old.txt new.txt
  4. Colours and word-by-word changes (needs Git)
    Terminal
    git diff --no-index --word-diff old.txt new.txt
  1. Show what changed
    Terminal · Ubuntu / Debian
    diff -u old.txt new.txt

    Lines starting with - are only in the first file. Lines starting with + are only in the second.

  2. Just check whether they differ
    Terminal · Ubuntu / Debian
    diff -q old.txt new.txt

    No output means they're the same.

  3. See it side by side
    Terminal · Ubuntu / Debian
    diff -y old.txt new.txt
  4. Colours and word-by-word changes (needs Git)
    Terminal · Ubuntu / Debian
    git diff --no-index --word-diff old.txt new.txt
  1. Show what changed
    PowerShell
    Compare-Object (Get-Content old.txt) (Get-Content new.txt)

    <= marks lines only in the first file. => marks lines only in the second. No output means they're the same.

  2. Line-by-line comparison
    PowerShell
    fc.exe old.txt new.txt
  3. Colours and word-by-word changes (needs Git)
    PowerShell
    git diff --no-index --word-diff old.txt new.txt