title: Bash - loop through array of objects and combine them
body: <p>I'm trying to create a for-loop to go through all the items from an array, and add the items to a string. The tags are given as a single string with format "tag1 tag2 tag3", and the tagging parameter can be given as many times as I want with the single command with syntax "-tag tag1 -tag -tag2 -tag tag3". I'm unable to create a for loop for the job, and I'm a little confused what is wrong with my code.</p>
  
  <pre><code>TAGS="asd fgh jkl zxc bnm" # Amount of tags varies, but there is always at least one
  ARRAY=($TAGS)
  TAGSTOBEADDED=""
  for i in "$ARRAY[@]"
  do
    STRINGTOBEADDED="-tag ${ARRAY[$i]}"
    $TAGSTOBEADDED=$TAGSTOBEADDED+$STRINGTOBEADDED
  done
  command $TAGSTOBEADDED
  </code></pre>