#!/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