Skip to content

Instantly share code, notes, and snippets.

@Aricg
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save Aricg/8944883 to your computer and use it in GitHub Desktop.

Select an option

Save Aricg/8944883 to your computer and use it in GitHub Desktop.
/usr/local/bin/remote_diff
#!/bin/bash
usage ()
{
cat << EOF
$0: diff the output of a command on two diffrent servers
Usage $0 user@host1 user@host2 "command"
EOF
exit 1
}
if [[ -z "$@" ]]; then usage
fi
#Assume root I do this so that complete -W works. I like pressing tab rather than typing.
if ! [[ "$1" == *@* ]]; then
firsthost="root@"$1""
else
firsthost="$1"
fi
if ! [[ "$2" == *@* ]]; then
secondhost="root@"$2""
else
secondhost="$2"
fi
#run remote diff
diff <(ssh $firsthost ""$3"" ) <(ssh $secondhost ""$3"")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment