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

0
730
How to Compare the Contents of Local & Remote Files with the Help of SSH


This is a step-by-step information on learn how to examine 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 check 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 technique to examine these recordsdata.

What if I instructed you there was a approach to do that with out having to first copy that file from one machine to a different? This ensures you don’t at all times should first copy a recent 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 completed.

Let’s say you’ve a file named check on each native and distant machines, and also you wish to examine the contents. To do that, open a terminal on one machine and enter the command

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

the place consumer is a legitimate username on the distant machine, host is the IP deal with of the distant machine and /path/to/file is the express 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 examine totally different recordsdata between native and distant machines with out having to first copy the recordsdata to or from one machine to a different. As at all times, 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.

LEAVE A REPLY

Please enter your comment!
Please enter your name here