title: copy and append files in ubuntu linux
body: <p>I have two folders each containing 351 text files and i want to copy the corresponding text from one folder to corresponding file in another folder?
  when i am using cat command i am getting an empty file as a result? what could be the problem</p>
  
  <p>my code is :</p>
  
  <pre><code>#!/bin/bash
  DIR1=$(ls 2/)
  DIR2=$(ls 3/)
  
  for each $i in $DIR1; do
  for each $j in $DIR2; do
  if [[ $i == $j ]];then
  sudo cat $i $j &gt;&gt; $j
  fi
  done
  done
  </code></pre>
  
  <p>2/ and 3/ are the folders containing the data...</p>