Where to start First steps track · 15 stages
Linux Labs

diff and patch — comparing and applying changes

cheat sheet · GNU diffutils https://lab.dimsanych.ru/en/wiki/diff-patch/

Cheat sheet

  • diff -u a b readable differences
  • diff -qr dir1 dir2 which files differ
  • diff <(cmd1) <(cmd2) compare the output of two commands
  • diff -u orig new > p.patch make a patch
  • patch orig < p.patch apply the patch
  • patch --dry-run -p1 < git.patch check it applies, without writing
  • patch -R < p.patch revert an applied patch
  • vimdiff a b side by side

Options

Below are the main flags of diff and patch; the full list is in man diff, man patch.

Loading…