tags:

views:

30

answers:

3

Hello,

Let's imagine that I have list of files at host1

find /path/to -name "*.jpg" -print

I want to connect to host2 via SSH and check that all files from this list are present on remote host.

Please help, how can I do this?

Thank you

A: 

Print files that don't exist on host2:

$ find /path/to -name "*.jpg" -print | ssh host2 "perl -lne'print unless -e'"
J.F. Sebastian
A: 

not tested.

find /path/to -name "*.jpg" -print >base.txt
ssh user@host2 "find /path/to -name '*.jpg'" > check.txt
diff <(sort base.txt) <(sort check.txt)
ghostdog74
A: 

I would use rsync in combination with ssh.

rsync -avn -e ssh ./ [email protected]:~/files/

This would do a dry run and list all files that are are on local machine, but not on the remote machine. It would also list files that may have been changed on the remote machine.

cb0