Hi
请问一下我想把tmp的值照一行行存入一个array, 希望rtn=("something is wrong 1","something is wrong 2","something is wrong 3").
除了改IFS或把空格以其他字串取代再换回来 有更好的写法吗? 谢谢
code:
tmp=`cat txt`
rtn=(`echo "tmp"`)
for ((i=0; i<${#rtn[@]}; i++))
do
echo ${rtn[i]}
done
希望结果
+ rtn='something is wrong 1
something is wrong 2
something is wrong 3'
+ (( i=0 ))
+ (( i<3 ))
+ echo something is wrong 1
something is wrong 1
+ (( i++ ))
+ (( i<3 ))
+ echo something is wrong 2
something is wrong 2
+ (( i++ ))
+ (( i<3 ))
+ echo something is wrong 3
something is wrong 3
+ (( i++ ))
+ (( i<3 ))