title: Difference between '2>&1' and '&>filename'
body: <p>I'm an beginner in Linux, I have a question about redirecting STDOUT and STDERR.</p>
  
  <ol>
  <li><p>Create a <code>file1</code> to add some strings</p>
  
  <pre><code>echo hello &gt; file1
  </code></pre>
  
  <p>After this, when I do something like this </p>
  
  <pre><code>cat file1 file2
  </code></pre>
  
  <p>It will give an error like this</p>
  
  <pre><code>hello
  cat: file2: No such file or directory
  </code></pre></li>
  <li><p>I want to redirect the STDOUT and STDERR, so </p>
  
  <pre><code>cat file1 file2 &gt; file3 2&gt;&amp;1 | cat
  hello
  cat: file2: No such file or directory
  </code></pre></li>
  <li><p>I know that <code>|</code> can use last command's output as its input, right?
  So the first <code>cat</code>'s output is:</p>
  
  <pre><code>hello
  cat: file2: No such file or directory
  </code></pre></li>
  <li><p>Now, I find another method to redirect output, like:</p>
  
  <pre><code>cat file1 file2 &amp;&gt; file3
  cat file3
  hello
  cat: file2: No such file or directory
  </code></pre></li>
  <li><p>It can do the same thing, but when I add <code>|cat</code> , the result is </p>
  
  <pre><code>cat file1 file2 &amp;&gt; file3 | cat
  hello
  </code></pre>
  
  <p>Where is the STDERR? It means only <code>hello</code> is the output of the first <code>cat</code>? </p></li>
  </ol>
  
  <p>What the difference between <code>2&gt;&amp;1</code> and <code>&amp;&gt;file</code>?</p>