I have a shell script which has a for loop that prints the value of an array element. The array size is 2 but when running the for loop with that array I m not getting proper output.
以下是 shell 脚本 :
#!/bin/bash
arry=$(ls /home/developer/.ssh/ | grep ".pub")
declare -a ARR
i=0
for key in $arry
do
ARR[i]=$(echo $key | sed s/.pub//g )
i=$((i+1))
done
echo ${#ARR[@]}
## the below for loop is not iterating as expected
for pri in $ARR
do
echo $pri
done
而不是现在提供输出
2
a
heroku
上述代码产生:
2
a
上面的外壳代码有什么问题?
我比较新 来弹空剧本 所以请原谅我的代码 你感觉不好
Attaching screenshot of the output