Article 5MXKZ Is there in bash scripts a way of using variables to specify different bash arrays

Is there in bash scripts a way of using variables to specify different bash arrays

by
stewate4
from LinuxQuestions.org on (#5MXKZ)
For example in this simple script

#!/bin/bash

declare -a MYARRAY1
declare -a MYARRAY2

function updatearray {
ARRAY=$1
VALUE=$2

$ARRAY+=$VALUE

}

updatearray MYARRAY1 "yyyy "
updatearray MYARRAY2 "bbbb "

echo "${MYARRAY1[@]}"
echo "${MYARRAY2[@]}"

exit 0

Just results in "line 10: MYARRAY1+=yyyy: command not found" rather than updating the array. This is actually for a more complex bash script I'm working on that has more arrays I want to update, so I'm hoping to avoid 'case' statements which would mean a big function bodylatest?d=yIl2AUoC8zA latest?i=gwZiOUcSbZc:zY9c_9sPx6Q:F7zBnMy latest?i=gwZiOUcSbZc:zY9c_9sPx6Q:V_sGLiP latest?d=qj6IDK7rITs latest?i=gwZiOUcSbZc:zY9c_9sPx6Q:gIN9vFwgwZiOUcSbZc
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments