小编pal*_*din的帖子

sh -c not get the right output when execute shell script

I loop to get data from array in shell ,
It works when I execute it in a shell file, with this content:

arr=(1 2 3 4 5)  
for var in ${arr[@]};  
do  
    echo $var  
done
Run Code Online (Sandbox Code Playgroud)

But there isn't any output when I use sh -c like below:

sh -c "arr=(1 2 3 4 5);for var in ${arr[@]};do echo $var;done"
Run Code Online (Sandbox Code Playgroud)

shell

2
推荐指数
1
解决办法
1078
查看次数

标签 统计

shell ×1