Skip to content

Instantly share code, notes, and snippets.

@beryllium
Created March 13, 2013 22:30
Show Gist options
  • Save beryllium/5157006 to your computer and use it in GitHub Desktop.
Save beryllium/5157006 to your computer and use it in GitHub Desktop.
So you're trying to piece together what exploded between two remote servers. You want to be able to diff files on them, but you don't want to be doing a whole bunch of manual file transfers. Enter: remote-diff.sh
#!/bin/bash
if [ -z "$1" -o -z "$2" -o -z "$3" ]
then
echo "Usage: remote-diff.sh [user@]host1 [user@]host2 path_to_file"
echo ""
echo "Note: If you need to specify a valid key or optional username for the host,"
echo " you are encouraged to add the host configuration to your ~/.ssh/config file."
exit 1
fi
#Inspired by a post on StackOverflow: http://serverfault.com/a/59147/114862
colordiff <(ssh "$1" cat "$3") <(ssh "$2" cat "$3")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment