【Linux】shell字符串分割、数组访问、条件判断

参考资料:

shell字符串分割再循环:http://www.shangxueba.com/jingyan/1633455.html

linux shell中 if else以及大于、小于、等于逻辑表达式介绍:http://www.jb51.net/article/34332.htm

Shell数组:shell数组的定义、数组长度:http://c.biancheng.net/cpp/view/7002.html

shell 数组长度:http://blog.csdn.net/shaobingj126/article/details/7395570

shell 数组长度:http://blog.csdn.net/lhf_tiger/article/details/18882223

 

示例代码:

API_Proxy_IP_List=(`echo ${API_Proxy_IP} | tr ";" "\n"`)
if [ ${#API_Proxy_IP_List[@]} -ne 1 ]; then
    echo "==========API_Proxy_IP Has More Than One Item, Do Nothing...=========="
else
    echo "==========API_Proxy_IP Has One Item, Update The /etc/hosts...=========="
    mungehosts -a "${API_Proxy_IP}  ${API_domain}"
fi

 

posted @ 2016-03-18 16:44  junneyang  阅读(1045)  评论(0编辑  收藏  举报