Mike Slinn
Mike Slinn

Merging a Remote File with a Local File

Published 2021-04-12.

This article is categorized under Bash, Open Source.

Today I am once again re-installing WSL2 on one of my laptops. Seems that a Windows 10 installation’s half-life is measured in months, after which time a reset is required. The reset preserves data, but not installed programs and not the WSL setup.

When I set up an OS I often use a pre-existing system’s files as templates for the new system’s files.


Meld is a fantastic, F/OSS file and directory merge tool. 2-way and 3-way merges are supported. Meld uses X Windows for its user interface. GWSL makes it easy to run X apps on WSL and WSL2.

$ sudo apt install meld

Merging a remote file with a local file using Meld is easy once you know how. Unless the remote file system is mounted locally, Meld cannot be used to modify remote files and directories, just local files and directories.

Following is the incantation I used to display my local .profile and interactively merge it with my profile on an Ubuntu Linux machine called gojira.

$ meld ~/.profile <(ssh mslinn@gojira cat .profile)&

The above runs ssh in a subshell, logs in as mslinn to the machine called gojira and then displays the contents of .profile on gojira. Meld compares the output of cat with the local copy of ~/.profile, and displays the differences:

Meld makes it easy to reconcile file versions. 😁