I would like to concatenate unlimited numbers of arrays using shortest lines possible, so for this I did the code below:
#!/bin/bash
declare -a list1=("element1")
declare -a list2=("element2")
declare -a list3=("element3")
declare -a list4=("element4")
declare -a list
for i in {1..4}
do
list=( ${list[@]} ${list$i[@]} )
done
echo ${list[*]}
But the code above is not working because $i is not seen as variable and the error is: ${list$i[@]} bad substitution
using shortest linesthen why do you use so many spaces?to concatenate unlimited numbersyou want to output them or store them in an array? Please be specific.