It looks like answer on my question is (almost):
rsync -a -c --existing /source/ /destination/
This will copy files which are different and as far as I understood silently synchronize timestamps of an equal files.
As usual firstly try it with -n
(or --dry-run
) key.
ADDED:
There is need to do what was mentioned in my question sometimes. So there is the script which does exactly what I asked for:
#!/bin/bash
# Ensure that there is a trailing '/'.
SRC="$(dirname $1)/$(basename $1)/"
DST="$(dirname $2)/$(basename $2)/"
if ! [[ -d "$SRC" ]] || ! [[ -d "$DST" ]]; then
echo "Usage:"
echo " $(basename $0) src/dir dst/dir"
exit 1
fi
diff -rqs "$SRC" "$DST" | grep -Po "(?<=^Files $SRC).*(?= and $DST.* are identical$)" | rsync -tv --files-from=- "$SRC" "$DST"