title: Avoid error with cat command when src file doesn't exist
body: <p>I am trying to copy content of file1 to file 2 using linux command</p>
  <p><code>cat file1 &gt; file2</code></p>
  <p>file1 may or may not be available depending on different environments where the program is being run. What should be added to the command in case file1 is not available so that it doesn't return an error ? I have read that appending 2&gt;/dev/null will not give error. While that's true, and I didn't get an error the command</p>
  <p><code>cat file1 2&gt;/dev/null &gt; file2</code>
  made file2's previous content completely empty when file1 wasn't there. I don't want to lose the content of file2 in case file1 wasn't there and don't want an error to return.</p>
  <p>Also in what other cases can the command fail and return an error ?</p>