title: Explain the bash command "exec > >(tee $LOG_FILE) 2>&1"
body: <p>My intent was to have all the output of my bash script displayed on the console and logged to a file.</p>
  
  <p>Here is my script that works as expected.</p>
  
  <pre><code>#!/bin/bash
  
  LOG_FILE="test_log.log"
  touch $LOG_FILE
  
  # output to console and to logfile
  exec &gt; &gt;(tee $LOG_FILE) 2&gt;&amp;1
  
  echo "Starting command ls"
  ls -al
  echo "End of script"
  </code></pre>
  
  <p>However I do not understand why it works that way.</p>
  
  <p>I expected to have <code>exec &gt;&gt;(tee $LOG_FILE) 2&gt;&amp;1</code> work but it fails although <code>exec &gt;&gt;$LOG_FILE 2&gt;&amp;1</code> indeed works.</p>
  
  <p>I could not find the reason for the construction <code>exec &gt; &gt;(command )</code> in the <a href="https://www.gnu.org/software/bash/manual/bash.html#Redirections" rel="noreferrer">bash manual</a> nor in <a href="http://tldp.org/LDP/abs/html/io-redirection.html" rel="noreferrer">advanced bash scripting</a>. Can you explain the logic behind it ?</p>