How do I Compare the Contents of Local & Remote Files with the Help of SSH

How do I Compare the Contents of Local & Remote Files with the Help of SSH.

This is a step-by-step information on how to match the contents of native and distant recordsdata with the assistance of SSH. Watch the companion video tutorial by Jack Wallen.

Have you ever wanted to match the contents of an area and distant file with out having to repeat the distant file to the native machine after which run the diff command on each? Sure, it’s not precisely a difficult job, but it surely’s not precisely essentially the most environment friendly option to evaluate these recordsdata.

What if I advised you there was a method to do that with out having to first copy that file from one machine to a different? This ensures you don’t all the time must first copy a contemporary model of the file to get essentially the most up-to-date content material. We do that with the assistance of the three instructions SSH, cat and diff, all of which needs to be put in in your Linux and macOS machines by default. Let me present you the way it’s achieved.

Let’s say you will have a file named take a look at on each native and distant machines, and also you need to evaluate the contents. To do that, open a terminal on one machine and enter the command

ssh person@host cat /path/to/file | diff /path/to/file -.

the place person is a sound username on the distant machine, host is the IP tackle of the distant machine and /path/to/file is the specific path to the file to be in contrast. After authenticating your distant account, diff will do its factor and print out the variations between the 2 recordsdata. And that’s all there’s to it.

With this helpful command, you possibly can evaluate completely different recordsdata between native and distant machines with out having to first copy the recordsdata to or from one machine to a different. As all the time, it’s higher to work smarter, not more durable.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the most recent tech recommendation for enterprise execs from Jack Wallen.


Check out more article on – How-To tutorial and latest highlights on – Technical News