版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012893325/article/details/79039011
shell string转为数组
代码如下
$ cat str2arr.sh
#!/bin/bash
str="i,like,you,csdn"
arr=(${str//,/ })
for s in ${arr[@]}
do
echo $s
done
执行结果
$ sh str2arr.sh
i
like
you
csdn