回答:
rsync -rvn localdir targetdir
-nは、アクションのみを表示することを意味します(アクションは実行されません)。
「v」が必要です。そうしないと何も表示されません。(残りの答えはこれを忘れます...)
他の回答とhttps://serverfault.com/a/618740/114520に基づいて構築する
--dry-run(または-n)を使用して変更を回避する--itemize-changes(または-i)を使用して変更を見つける--archive(または-a)を使用してすべてのサブディレクトリを取得しますegrepドットで始まるエントリをフィルタリングするために使用します(変更なし)それはあなたに与えます: rsync -nia source destination | egrep -v "sending incremental file list" | egrep -v "^\."
1つの方法だけが必要な場合は、コマンドを変更できます。
rsync -nia source destination | egrep -v "sending incremental file list" | egrep -v "^(\.|<)"rsync -nia source destination | egrep -v "sending incremental file list" | egrep -v "^(\.|>)"ファイルのみが必要な場合は、awk魔法を追加するだけです。rsync -nia source destination | egrep -v "sending incremental file list" | egrep -v "^\." | awk '{print $2}'
私はこのようなものに行きます:
#! /bin/bash 
set -eu   ## Stop on errors and on undefined variables
## The local directory name
LOCAL_DIR=$1
## The remote directory in rsync sintax. Example: "machine:directory"
REMOTE_DIR=$2
shift 
shift 
# Now the first two args are gone and any other remaining arguments, if any, 
# can be expanded with $* or $@
# Create temporary file in THIS directory (hopefully in the same disk as $1:
# we need to hard link, which can only made in the same partition)
tmpd="$(mktemp -d  "$PWD/XXXXXXX.tmp" )"
# Upon exit, remove temporary directory, both on error and on success
trap 'rm -rf "$tmpd"' EXIT
# Make a *hard-linked* copy of our repository. It uses very little space 
# and is very quick 
cp -al "$LOCAL_DIR" "$tmpd"
# Copy the files. The final «"$@"» allows us to pass on arguments for rsync 
# from the command line (after the two directories).
rsync -a "$REMOTE_DIR"/   "$tmpd/"  --size-only "$@"
# Compare both trees
meld "$LOCAL_DIR"  "$tmpd"
例えば:
$ cd svn 
$ rsyncmeld myproject othermachine:myproject -v --exclude '*.svn' --exclude build
              問題の真実は、実行rsync -v ...してファイル名を画面に出力する場合、そのファイルは転送されている(または--dry-runを実行している場合は転送されている)ことです。rsyncが転送しようとした理由を確認するには、itemizeモードを使用します:https : //serverfault.com/a/618740/27813
他の人が指摘したように、デフォルトでは、rsyncはファイルサイズとタイムスタンプに基づいて比較するだけです。どのファイルが異なるかを本当に見たい場合は、「-c」チェックサムモードを使用します。
--dry-run使用に依存します。したがって、出力がまったく得られない場合は、必要に応じてこれらのオプションを設定します。ファイルが変更されていない場合でもディレクトリ名を送信することに気づきましたが、出力を渡すなどして、これらを除外できます。-v--progress optionssed