[TUHS] Be there a "remote diff" utility?

Alan D. Salewski ads at salewski.email
Thu Jun 20 09:20:24 AEST 2024


On Thu, May 16, 2024, at 15:53, Theodore Ts'o wrote:
> On Thu, May 16, 2024 at 04:34:54PM +1000, Dave Horsfall wrote:
>> Every so often I want to compare files on remote machines, but all I can 
>> do is to fetch them first (usually into /tmp); I'd like to do something 
>> like:
>> 
>>     rdiff host1:file1 host2:file2
>> 
>> Breathes there such a beast?  I see that Penguin/OS has already taken 
>> "rdiff" which doesn't seem to do what I want.
[...]

> In any case, the way I'd suggest that you do this that works as an
> extention to the Unix philosohy of "Everything looks like a file" is
> to use FUSE:
>
> sshfs host1:/ ~/mnt/host1
> sshfs host2:/ ~/mnt/host2
> diff ~/mnt/host1/file1 ~/mnt/host2/file2
>
> Cheers,
>
> 					- Ted

Mentioning this since I just came across it today: Eric S. Raymond
(ESR) has a 'netdiff' tool available here:

     http://www.catb.org/~esr/netdiff/
     https://gitlab.com/esr/netdiff

<quote>
    Perform diff across network links.

    Takes two arguments which may be host:path pairs in the style of
    ssh/scp, make temporary local copies as needed, applies
    diff(1). All options are passed to diff(1).
</quote>

Usage:
    netdiff [diff-options] [host1:]path1 [host2:]path2

It's 56 lines of POSIX shell script that invokes 'scp' behind the
scenes and creates temp files that are fed to 'diff', with some file
name post-processing.

Compared to the one line of shell script mentioned by Arnold:

    diff -u <(ssh host1 cat file1) <(ssh host2 cat file2)

the main benefits I see to 'netdiff' in its current form are that it
encapsulates the mechanism behind a descriptive name that can be
found in the file system, and it has a man page. So it can be found,
used and/or studied by those with larval shell fu.

However, the comments in the 'netdiff' source suggest openness to
supporting different transport mechanisms, which (if added) might
allow using the same command line interface regardless of the
underlying transport being used (scp, ssh, rsync, curl, wget,
whatever), possibly with different transports for each of the
requested files.

Of course, that would not offer a superior user experience to the
'9import', 'sshfs', and NFS approaches also mentioned.

But if there were an 'rf' ("remote file") tool that did just the
transport abstraction portion, then tools such as 'netdiff' could
use it internally, or folks could use it directly:

    diff -u <(rf user at host1:/path/to/file1) <(rf user at host2:/path/to/file2)

The presumption here is that the user has control over some local
configuration that maps user at host pairs to transports (maybe
defaulting to 'ssh' invoking 'cat' on the remote host).

Maybe somebody who needs more than 'ssh' would find value in such a
thing...

-Al

-- 
a l a n   d.   s a l e w s k i
ads at salewski.email
salewski at att.net
https://github.com/salewski


More information about the TUHS mailing list