【发布时间】:2019-09-29 21:25:44
【问题描述】:
while read -r line
do
local format=()
for c in "$line"
do
format+=("$line")
done
for ((x=0; x< ${#format[@]} ;x++)) # this part just iterate 0
##index because whole string
#stores only 0 index
do
echo "${format[$x]} $x "
done
done <$1
此代码仅将数据存储在 0 索引中,例如我有一个字符串是“你好,这是我的世界”,这整个字符串存储在 0 索引中,但我想将每个单词分别存储在字符串中。如何我可以这样做吗?
这就是我想要的 ==[hello,this,is,my,world]
【问题讨论】:
-
这可能会有所帮助:How to debug a bash script?
标签: bash shell command-line terminal