for循环读取变量


#!/bin/bash # #这里默认空格是分隔符 list="zhangSan Lisi WangEr Tom" for i in $list do echo "Name is $i"
done

运行结果是:

for循环读取变量

 

 2.IFS修改默认分隔符

#!/bin/bash
#

IFS=":"
list="zhangSan Lisi WangEr Tom"
for i in $list
do
        echo "Name is $i"
done

运行结果是:

 for循环读取变量

 

上一篇:shell编程:for循环


下一篇:C++ 文件操作I/O流