for循环读取变量


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

运行结果是:

 

 2.IFS修改默认分隔符

#!/bin/bash
#

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

运行结果是:

 

 

posted @ 2020-06-06 15:49  天凉好个秋秋  阅读(292)  评论(0编辑  收藏  举报