title: Combining multiple outputs from a loop into one text file with commas in Bash
body: <p>I am testing out a method of motion detection using bash script. I am running an ImageMagick compare command and outputting the result into a text file. </p>
  
  <p>A loop creates one output every time it runs through. I want each output to be placed into a single text file and to be separated by commas.</p>
  
  <p>The code I am using is currently:</p>
  
  <pre><code>for (( x=1; x&lt;=$vidLength; x++))
  do
  
  #Compare current frame with previous, saving result as "difference-current"png
  compare -metric RMSE -fuzz 5% previous-001.png current-001.png difference+%x+.png 2&gt;&gt; motionData.txt    
  
  Done
  </code></pre>
  
  <p>This code does proceed to put all of the data into one text file, but the data is displayed together, and just looks like one big number.</p>
  
  <p>At the moment the data is put into the text file, however it is displayed like:
  "4873343460936622743393154537"</p>
  
  <p>When I want it to read:
  "4873,343,4609,366,2274,339,315,4537"</p>