Created
November 29, 2018 21:35
-
-
Save nievergeltlab/18607e747e256d2493c2d8bd2c12d456 to your computer and use it in GitHub Desktop.
Compare two directories to reconcile them
This file contains hidden or 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
| src='/run/media/genetics/pgc_ptsd/broad/gracy' # Source directory | |
| dst='/run/media/root/_gen/pts1/gracy' # Destination directory | |
| icp() { | |
| f="${1}"; | |
| [ -d "$f" ] && { | |
| [ ! -d "${dst}${f#$src}" ] && mkdir -p "${dst}${f#$src}"; | |
| return | |
| } | |
| [ ! -f "${dst}/${f#$src/}" ] && { cp -a "${f}" "${dst}/${f#$src/}"; return; } | |
| fsizeSrc=$( stat -c %s "$f" ) | |
| fsizeDst=$( stat -c %s "${dst}/${f#$src/}" ) | |
| [ ${fsizeDst} -lt ${fsizeSrc} ] && echo "copying "${f}"" && cp -a "${f}" "${dst}/${f#$src/}" | |
| } | |
| export -f icp | |
| export src | |
| export dst | |
| find ${src} -exec bash -c 'icp "$0"' {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment