I am trying to add an element to a bash array. I looked at this question and tried to follow its advice.
This is my code:
selected_projects=()
for project_num in ${project_numbers[@]}; do
selected_project=${projects[$project_num]}
echo "selected project: $project_num $selected_project"
$selected_projects+="$selected_project"
done
When I do this, I get an error:
line 88: +=someProject: command not found
I tried many different alternatives to that line with lots of parenthesis and dollar signs, but I cannot figure out what I'm doing wrong and what it should be. Any ideas?
Thanks!
selected_projects+="$selected_project"
instead of$selected_projects+="$selected_project"
– MichalH Jun 19 '20 at 19:25