compare contents of two directories on remote server using unix

前端 未结 4 916
鱼传尺愫
鱼传尺愫 2020-12-12 14:16

I am new to unix and need some help here. I have two directories present on two different server. both the directories contains the same files. Now i want to check if all fi

4条回答
  •  旧巷少年郎
    2020-12-12 14:49

    You can use rsync with the -n flag to find out if the files are in sync, without actually doing a sync.

    For example, from server1:

    rsync -n -avrc /abc/home/sample1/* server2:/abc/home/sample2/
    

    This will print the names of all files (recursive, with the -r flag) that differ between server1:/abc/home/sample1/ and server2:/abc/home/sample2/

    rsync used parameters explanation

    -n, --dry-run - perform a trial run with no changes made

    -a, --archive - archive mode; equals -rlptgoD (no -H,-A,-X)

    -v, --verbose - increase verbosity

    -r, --recursive - recurse into directories

    -c, --checksum - skip based on checksum, not mod-time & size

提交回复
热议问题