Skip to content

Instantly share code, notes, and snippets.

@therealchjones
Last active November 24, 2024 22:34
Show Gist options
  • Select an option

  • Save therealchjones/067d7fd6f74bf9dff31fbed112f5a15e to your computer and use it in GitHub Desktop.

Select an option

Save therealchjones/067d7fd6f74bf9dff31fbed112f5a15e to your computer and use it in GitHub Desktop.
Using rsync to compare directory hierarchies

Comparing directories with rsync

Syntax

rsync trailing /

Remember the eccentricities of rsync trailing slash behavior:

rsync /path/to/dir1 /other/path/to/dir2

results in the directory /other/path/to/dir2/dir1 synchronizing with /path/to/dir1, while

rsync /path/to/dir1/ /other/path/to/dir2

makes /other/path/to/dir2 itself sync with /path/to/dir1. (A trailing / on the target directory makes no difference.) Here, we'll consistently use the second (trailing /) version to try to avoid confusion.

Options

Comparisons

Compare two directories and all their contents in the usual rsync way, by name, size, and modification time:

rsync -rltni dir1/ dir2/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment