Bash Scripting - Arrays
What is wrong with this Bash code snippet for slicing an array?
arr=(x y z)
echo ${arr:1:2}arr=(x y z)
echo ${arr:1:2}${arr:1:2} without @. For arrays, @ is needed to slice multiple elements.@, Bash uses the first element x as a scalar string and slices it from index 1 length 2. Since x has length 1, it outputs an empty string.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions