Super SCP
Written by Arnaud no commentsI use this script to scp files as root to the distant server, so that I don't need to type "root@"
eg : arnaud@local:~$./scp file srv:/root
#!/bin/bash
# we check the last argument
if [ `echo ${!#} | grep ":"` ] ; then
# we pop $@
# sed s,a,b is same as sed s/a/b
# but no need to escape / :-)
list=$(echo $@ | sed s,\ ${!#},,)
scp -r $list root@${!#}
else
# we unshift $@
list=$(echo $@ | sed s,$1\ ,,)
scp -r root@$1 $list
fi