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 ×1