 <p>What about <code>set -v</code>?</p> <blockquote> <p><code>-v</code> Print shell input lines as they are read.</p> </blockquote> <p>The output seems to meet your expectation.</p> <pre><code>$ set -v $ ./command1 &gt; output1 ./command1 &gt; output1 sh: ./command1: No such file or directory $ ./command2 arg1 arg2 &gt; output2 ./command2 arg1 arg2 &gt; output2 sh: ./command2: No such file or directory $ ./command3 | tee output3 ./command3 | tee output3 sh: ./command3: No such file or directory </code></pre>