title: how can i add to a file from a scalar in bash?
body: <p>I'm writing a function that'll accept 2 arguments - the name of a scalar and and a filename and will write the scalar (newline delimited) to that file. I'm getting a "bad substitution" error. Here's my code:</p>
  
  <pre><code>#!/bin/bash
  
  arr_to_f() {
  for y in "${1[@]}"
         do
         echo "$y" &gt;&gt; "$2"
         done
  }
  
  mapfile -t arr &lt; &lt;(echo "one" ; echo "two" ; echo "three")
  
  arr_to_f arr file
  </code></pre>
  
  <p>I could do it outside the function using my loop  but ill be using this a lot i think so id rather be able to call it if possible.</p>