leafsummer
1/21/2016 - 10:21 AM

scp all file in some dir to the other machine

scp all file in some dir to the other machine

#!/bin/bash

# echo $#
if (($# < 2)); then
    echo "miss params"
    exit 1
fi
echo "params: $@"
# echo "scp dir ${!#}"

count=1
for param in "$@"
do
    if (($count < $#)); then
        echo "scp ${!#}* root@$param:${!#}"
        scp "${!#}"* root@$param:"${!#}"
        count=$(($count + 1))
    fi
done