Skip to content

Instantly share code, notes, and snippets.

@chrisb13
Created October 7, 2015 23:33
Show Gist options
  • Save chrisb13/432eade90ec68629d03a to your computer and use it in GitHub Desktop.
Save chrisb13/432eade90ec68629d03a to your computer and use it in GitHub Desktop.
function servername_push()
{
if [[ ( $# -eq 0 ) || ( $1 == "--help" ) || ( $1 == "-h" ) ]] ; then
echo "Usage: servername_push PATH_FROM PATH TO."
echo "Purpose: rsync function to push files to servername."
echo " "
echo "Mandatory arguments: "
echo "PATH_FROM: Path on local to Rsync from"
echo "PATH_TO: Path on server to Rsync to"
echo " "
echo "Example."
echo "This:"
echo "servername_push ./temp/* /home/server/path/"
echo " "
echo "Becomes:"
echo "rsync -avz --progress ./temp/* server_username@server.address.edu.au:/home/server/path/"
return 1
fi
#grabs last passed argument..
for last; do true; done
#grabs all arguments but the last one...
#echo ${@:1:$(($#-1))}
rsync -avz --progress ${@:1:$(($#-1))} server_username@server.address.edu.au:$last
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment