Last active
December 11, 2015 00:39
-
-
Save 17twenty/4518182 to your computer and use it in GitHub Desktop.
Simple bash script to print out an rsync command for use with copying files from a remote system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Simple script to create a pastable rsync command | |
foo="$(readlink -f "$1")" | |
# Use everybodys favourite Dynamic IP address checker to get our external IP address. | |
my_external_ip=$(wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//') | |
#echo $my_external_ip | |
# Add the slashes in to escape stuff | |
foo=$(echo "$foo" | sed -e 's/ /\\ /g') | |
foo=$(echo "$foo" | sed -e 's/-/\\-/g') | |
foo=$(echo "$foo" | sed -e 's/(/\\(/g') | |
foo=$(echo "$foo" | sed -e 's/)/\\)/g') | |
boilerplate="rsync -r --progress -h $(whoami)@$my_external_ip:" | |
echo -e "\e[0;31m$boilerplate\"$foo\" ." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment