Skip to content

Instantly share code, notes, and snippets.

@bcreasy
Last active August 29, 2015 14:01
Show Gist options
  • Save bcreasy/741970b1a3e799dbba98 to your computer and use it in GitHub Desktop.
Save bcreasy/741970b1a3e799dbba98 to your computer and use it in GitHub Desktop.
create subdir tree before scp
scpr() {
# usage: scpr filename user@hostname:/tmp/sub/dir/
remote_host=${2%%:*}
remote_path=${2##*:}
remote_dir=${remote_path%/*}
file=${remote_path##*/}
ssh $remote_host mkdir -p ${remote_dir}
scp $1 $remote_host:$remote_dir
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment