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 ))