Skip to content

Instantly share code, notes, and snippets.

@shivams
Last active July 27, 2023 12:28
Show Gist options
  • Save shivams/4371e8ee68d39d9b1b7f0c2ccccd725e to your computer and use it in GitHub Desktop.
Save shivams/4371e8ee68d39d9b1b7f0c2ccccd725e to your computer and use it in GitHub Desktop.
Rsync --dry-run issue
mkdir ~/temp && cd ~/temp
mkdir dir1 dir2
cd ~/temp/dir1
echo Hello > a.txt
echo World > b.txt
cp -p ~/temp/dir1/b.txt ~/temp/dir2
# Now, dir2 contains "b.txt" file from dir1
# Hence, using rsync dry-run, it should only show "a.txt" as the file that is going to be transferred.
# NOTE: We used the -p flag to ensure that all metadata of "b.txt" is preserved.
rsync --dry-run -iav ~/temp/dir1 ~/temp/dir2
# OUTPUT:
# sending incremental file list
# cd+++++++++ dir1/
# >f+++++++++ dir1/a.txt
# >f+++++++++ dir1/b.txt
# The output is showing both a.txt and b.txt, whereas we expected only a.txt as the file that differs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment