Skip to content

Instantly share code, notes, and snippets.

@mrclay
Created March 20, 2012 20:54
Show Gist options
  • Save mrclay/2141182 to your computer and use it in GitHub Desktop.
Save mrclay/2141182 to your computer and use it in GitHub Desktop.
Compare two remote directories
#!/bin/bash
# Compares two remote directories using git diff (for color) by
# first copying all remote contents to local.
#
# USAGE: ./remote_diff path/from/www
TEMP1=~/.tmp_srv1_
TEMP2=~/.tmp_srv2_
CONNECT1="username@hostname1:/var/www/$1"
PORT1=22
CONNECT2="username@hostname2:/var/www/$1"
PORT2=22
rm -rf "$TEMP1"
rm -rf "$TEMP2"
mkdir "$TEMP1"
mkdir "$TEMP2"
scp -rq -P "$PORT1" "$CONNECT1" "$TEMP1"
scp -rq -P "$PORT2" "$CONNECT2" "$TEMP2"
echo -e "\n\n\n\n\n"
clear
git diff -U "$TEMP2" "$TEMP1"
rm -r "$TEMP1"
rm -r "$TEMP2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment