Skip to content

Instantly share code, notes, and snippets.

@shello
Last active December 27, 2015 19:19
Show Gist options
  • Save shello/7376146 to your computer and use it in GitHub Desktop.
Save shello/7376146 to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
# Retrieves a remote file to a temporary local file, and prints its path
remotetmp() {
REMOTE_TMPFILE=`mktemp`
scp -q $1 $REMOTE_TMPFILE
if [[ $? == 0 ]]; then
print $REMOTE_TMPFILE;
fi
}
# Examples:
# $ remotetmp host:path/file
# Simple usage, retrives `path/file` from the host `host`,
# prints the path of the file
# $ diff `remotetmp host:path/file` path/file
# Compares a remote `path/file` in `host` with a local `path/file`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment