13

Issue with array in shell

view full story
linux-howto

http://www.unix.com – So i have used arrays for a while now but I just notice in one of my arrays when using an array with 9+ items in it that after running a for loop on the array it was replacing the first array with what ever was last and I cant figure out why. Here is my code. Code: #!/bin/bash vm=( 0 1 2 3 4 5 6 7 8 9 10 ) echo before for loop array=${vm[@]} for vm in ${vm[@]} do         echo $vm done echo after for loop array=${vm[@]} before for loop array=0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10 after for loop array=10 1 2 3 4 5 6 7 8 9 10 (HowTos)