shell解析IP列表

将一串配置的IP地址解析出来,每个IP以“,”号分割,shell代码如下:

#!/bin/bash

str="192.168.12.1,192.168.12.2,192.168.12.3"
echo $str
arry=(${str//,/ })

for each in ${arry[@]}
do
    echo $each
done
 
 
[root@klm-32 sh]# ./test_arry.sh 
192.168.12.1,192.168.12.2,192.168.12.3
192.168.12.1
192.168.12.2
192.168.12.3

猜你喜欢

转载自blog.csdn.net/kongshuai19900505/article/details/79484723