How to diff directories over ssh

前端 未结 4 1019
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-22 22:39

I am trying to recursively compare a directory in the local host to a directory in a remote linux machine. However, when i execute the next command:

diff -r          


        
相关标签:
4条回答
  • 2020-12-22 23:02

    I find krusader very useful for such task in case you need a GUI. See https://www.linux.com/news/synchronize-directories-komparator-and-kdiff3 for more details http://krusador.org.

    example folder compare

    0 讨论(0)
  • 2020-12-22 23:03

    You can mount the remote directory via sshfs, then you can use diff -r to compare the two directories as you want to do it.

    Alternatively you could run similar find commands on both machines to print the file trees (e. g. file names, sizes, and dates) and then compare the outputs of both using diff. This would not compare file contents, of course:

    diff <(ssh host find /home/admin -printf '"%8s %P\n"') \
         <(find /home/admin -printf '%8s %P\n')
    

    Notice the double quoting of the printf-format string in the ssh call. One layer is removed by the ssh relay.

    0 讨论(0)
  • 2020-12-22 23:06

    Try using "rsync" with the "-n" option, which just does a "dry run" and tells you what it would do.

    0 讨论(0)
  • 2020-12-22 23:09

    If you needn't diff the detail in file, just get the difference of dir/file name, then try this:

    (Note: need set "SSH login without password" , for detail , review this URL: http://www.linuxproblem.org/art_9.html)

    diff <(ssh admin@10.0.0.10 ls -R /home/admin) <(ls -R /home/admin)
    
    0 讨论(0)
提交回复
热议问题