Created
June 29, 2015 10:22
-
-
Save eriksimonic/e1d05a9f9be328d2e62c to your computer and use it in GitHub Desktop.
Copy only differing files from one location to another location. (A|B = B-A)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SOURCE=source/ | |
DESTINATION=destination/ | |
DESTINATION_DIFF=destination_diff/ | |
DIFF_FILE=differences.txt | |
DIFF_FILE_TMP=differences_tmp.txt | |
diff -bBqTrqN $SOURCE $DESTINATION >$DIFF_FILE | |
sed 's/Files //' $DIFF_FILE > $DIFF_FILE_TMP | |
sed 's/ and .*$//' $DIFF_FILE_TMP > $DIFF_FILE | |
rm $DIFF_FILE_TMP | |
rsync -av --files-from=$DIFF_FILE ./ $DESTINATION_DIFF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment