原文链接:http://1985wanggang.blog.163.com/blog/static/776383320121745626320/ a="one,two,three,four" 要将$a分割开,可以这样: OLD_IFS="$IFS" IFS="," arr=($a) IFS="$OLD_IFS" for s in ${arr[@]} do echo "$s" done 上述代码会输出 one
参考资料: 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/shaobingj