how can i save "read " error output in shell script? <p>I write a bash file in which i used <code>read</code> command to read data from a file.</p> <p>If the file wasn't there I want to save the error into a text file. I tried:</p> <pre><code>read myVariable &lt; myFile 2&gt; errorFile.txt </code></pre> <p>it doesn't work, and many other efforts faild such as:</p> <pre><code>myVar=`read myVariable &lt; myFile` </code></pre>