I know that bash supports some kind of list data structure:
list="1 2 3"
for i in $list; do
echo "$i"
done
But what about arrays? Does bash have array data structure? And if so, how it would look like?
I know that bash supports some kind of list data structure:
list="1 2 3"
for i in $list; do
echo "$i"
done
But what about arrays? Does bash have array data structure? And if so, how it would look like?
There's a few different notations for arrays in bash.
You can define an array like name[index]=value, or like name=(val1 val2 val3), or explicitly declare an array using declare -a ARRAYNAME. You can reference individual elements of an array with ${name[index]} or the whole array with ${name[@]}.