Mike Slinn

Merging a Remote File with a Local File

Published 2021-04-12.
Time to read: 1 minutes.

This page is part of the posts collection, categorized under Bash, Open Source, Ubuntu.

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

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.

Shell
$ yes | 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.

Shell
$ 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.

* indicates a required field.

Please select the following to receive Mike Slinn’s newsletter:

You can unsubscribe at any time by clicking the link in the footer of emails.

Mike Slinn uses Mailchimp as his marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp’s privacy practices.