title: How to append custom string to error output and redirect it to a file
body: <p><strong>Given</strong>:</p>
  
  <p>An <code>ffprobe</code> command that detects duration of an <code>mp4</code> video files on a remote host.</p>
  
  <p><strong>Expected</strong>:</p>
  
  <p>Output of <code>ffprobe</code> is prefixed with custom string and redirected to a text file.</p>
  
  <p><strong>Problem</strong>:</p>
  
  <p>Sometimes due to network error, <code>ffprobe</code> fails with some error message. I would like to capture that error, prefix it with a custom string and send it to a text file.</p>
  
  <p><strong>Example</strong>:</p>
  
  <p>This command appends "ABC=55" to <code>out.txt</code> where 55 is the discovered duration:</p>
  
  <blockquote>
    <p>ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 <a href="https://example.com/video.mp4" rel="nofollow noreferrer">https://example.com/video.mp4</a>' | awk '{print "ABC="$1}' 2>&amp;1 >> out.txt</p>
  </blockquote>
  
  <p>However, if that same command encounters a network error, instead of writing "ABC=Error message here", it writes noting to text file and shows that message in console.</p>
  
  <p><strong>Question</strong></p>
  
  <p>How do I tweak this part to capture execution errors, prefix them with "ABC=" and send to <code>out.txt</code>?</p>
  
  <blockquote>
    <p>| awk '{print "ABC="$1}' 2>&amp;1 >> out.txt</p>
  </blockquote>
  
  <p>Thank you.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This solved the problem:</p>
  
  <blockquote>
    <p>2>&amp;1 | awk '{print "ABC="$0}'</p>
  </blockquote>