In Shell script i am trying to pass an array to a Sudo SU command as shown below
VAR=(1,2,3)
sudo su $USER -c "for p in ${VAR[@]} ; do echo $p ; done;"
Issue is $p value is not getting printed. I have tried all the below possible way but not able to print $p value
sudo su $USER -c "for p in "${VAR[@]}" ; do echo "$p" ; done;"
sudo su $USER -c 'for p in ${VAR[@]} ; do echo $p ; done;'
Sample Output of the command
+ sudo su USER -c 'for p in 1 2 3 4 5 ; do echo ; done;'
+ echo "Script Ended"