使用unix比较远程服务器上两个目录的内容 [英] compare contents of two directories on remote server using unix

查看:60
本文介绍了使用unix比较远程服务器上两个目录的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是unix的新手,在这里需要一些帮助. 我在两个不同的服务器上有两个目录.这两个目录包含相同的文件.现在,我想检查两个目录中的所有文件是否都同步.如果文件不同步,那么我只想显示那些文件的名称. 当目录位于同一服务器上时,我能够执行此操作.当目录位于两个不同的服务器上时,无法弄清楚该怎么做.

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 files are in sync in both the directories. If files are not in sync then i want to display only name of those files. I am able to do it when directories are on same server. not able to figure out how to do this when directories are present on two different servers.

eg:
server1 /abc/home/sample1/
server2 /abc/home/sample2/

在这里,我只希望不同步时显示文件名.

here i want only files name to display when it not in sync.

预先感谢

推荐答案

您可以将rsync与-n标志一起使用,以查找文件是否同步,而无需实际进行同步.

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

例如,来自 server1 :

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

这将打印在server1:/abc/home/sample1/server2:/abc/home/sample2/

rsync使用的参数说明

-n, --dry-run-在不做任何更改的情况下进行试运行

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

-a, --archive-存档模式;等于-rlptgoD(没有-H,-A,-X)

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

-v, --verbose-增加详细程度

-r, --recursive-递归到目录

-c, --checksum-跳过基于校验和,而不是基于mod-time&大小

这篇关于使用unix比较远程服务器上两个目录的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆