How to concatenate an array with itself in bash?
12:55 30 Jun 2015

How can I read lines from the standard input into an array and then concatenate the array with itself?

My code is:

countries=()
while read -r country; do
    countries+=( "$country" )
done
countries=countries+countries+countries # this is the wrong way, i want to know the right way to do it
echo "${countries[@]}"

Note that, I can print it thrice like the code below, but it is not my motto. I have to concatenate them in the array.

countries=()
while read -r country; do
    countries+=( "$country" )
done
echo "${countries[@]} ${countries[@]} ${countries[@]}"
arrays bash shell concatenation