Thursday, August 18, 2011

Comparing files across linux or unix boxes

I recently had the problem of needing to compare files across linux boxes. The problem was that I wanted to diff them easily. After some trial and error I found out how to easily diff two files on two different boxes.


ssh user@myserver.com "cat /var/www/html/myfile.php" |diff - myfile.php


What this does is SSH into the box, then cat the output of the file. This is piped into diff and then compared to the local file.

I used the -b option as well (though not shown) to ignore white space changes since they were html files.

This saved a lot of time comparing files vs copying them to a local filesystem and doing a diff there.

No comments: