title: bash creating a csv file
body: <p>I would like to create a csv file. The filename of the .txt file should be the header and all jpgs files inside the .txt file should be the rows.</p>
  
  <p>Example:</p>
  
  <pre><code>filename1.txt, filename2.txt, filename3.txt
  filename1a.jpg,filename2a.jpg,filename3a.jpg
  filename1b.jpg,filename2b.jpg,filename3b.jpg
  filename1c.jpg,filename2c.jpg,filename3c.jpg
                ,filename2d.jpg,
  </code></pre>
  
  <p>The problem I am having is how to append to file with the right format as above?</p>
  
  <pre><code>for f in $(ls *.txt) do
      csv_header="$f"
      #get all jpgs in current txt file
      array_jpgs=( $(get_jpgs "$f") )
      for jpg in "${array_jpgs[@]}" do
          #printf "%s," "$csv_header" &gt;&gt; "$CSV_FILE"
      done
  done
  </code></pre>
  
  <p>I am using GNU bash, version 4.3.33 </p>