dev*_*ull 28
为了将字符串转换为数组,请说:
$ str="title1 title2 title3 title4 title5"
$ arr=( $str )
Run Code Online (Sandbox Code Playgroud)
除非引用字符串,否则shell将对空格执行单词拆分.
为了遍历由此创建的数组中的元素:
$ for i in "${arr[@]}"; do echo $i; done
title1
title2
title3
title4
title5
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
27158 次 |
| 最近记录: |