(13) 批量随机复制
#!/bin/bash
while getopts f: OPT;
do
case $OPT in
f|+f)
files="$OPTARG $files"
;;
*)
echo "usage: `basename $0` [-f hostfile] <from> <to>"
exit 2
esac
done
shift `expr $OPTIND - 1`
if [ "" = "$files" ];
then
echo "usage: `basename $0` [-f hostfile] <from> <to>"
exit
fi
for file in $files
do
if [ ! -f "$file" ];
then
echo "no hostlist file:$file"
exit
fi
hosts="$hosts `cat $file`"
done
for host in $hosts;
do
echo "do $host"
scp $1 root@$host:$2
done
#need hosts file
#example use
## ./randomcopy.sh -f ./hosts /usr/local/source /usr/local/
作者:admin 创建时间:2023-04-27 13:46
最后编辑:admin 更新时间:2024-07-17 15:26
最后编辑:admin 更新时间:2024-07-17 15:26