title: Appending to file in bash loop is adding ^M
body: <p>I'm running a Bash script that loops through the files in a directory and appends them all to a single file.</p>
  
  <p>However, I find that ^M is being added to the end of every line.</p>
  
  <p>The original files do not contain this escape character and manually appending the files on the command line does not insert the character.</p>
  
  <p>I don't know if it matters, but I'm using eval to construct and then retrieve the directory names as below:</p>
  
  <p>Construct directory names:</p>
  
  <pre><code>declare ${schema}_${type}_${subtype}="$(eval echo \$${schema}_${type}_${subtype}) $(echo $file | egrep -v "$excluded_types" | grep $schema/$type/$subtype)"
  </code></pre>
  
  <p>Retrieve directory names:</p>
  
  <pre><code>for file in $(eval echo \$${schema}_${type}_${subtype})
  do
    echo -e "\t\t\t$file"
    echo -e "\t\t\t$file\n" &gt;&gt; $log_file
    cat $file &gt;&gt; $output_file
  done
  </code></pre>