[root@localhost ~]# for i in `seq 1 5`;do echo 192.168.1.$i /var/$i /var/$i;done > ip_list.txt
[root@localhost ~]# cat ip_list.txt |awk '{print $1}'
192.168.1.1
192.168.1.2
192.168.1.3
192.168.1.4
192.168.1.5
[root@localhost ~]# cat ip_list.txt |awk '{print $2}'
/var/1
/var/2
/var/3
/var/4
/var/5
[root@localhost ~]# cat ip_list.txt |awk '{print $3}'
/var/1
/var/2
/var/3
/var/4
/var/5
vim for.sh 批量拷贝文件
#!/bin/bash
while read i
do
IP=`echo $i |awk '{print $1}'`
SRC=`echo $i |awk '{print $2}'`
DES=`echo $i |awk '{print $3}'`
echo scp -r $SRC/* root@$IP:$DES/
done < ip_list.txt
原文链接:https://www.f2er.com/bash/391254.html