title: Get the exit code status of second to last command that was run
body: <p>say I have a set of commands like</p>
  <pre><code>touch /tmp/file.json
  tool test --json |&amp; tee /tmp/file.txt
  
  firstchar=$(head -c 1 /tmp/file.txt)
  ret=$?
  
  
  #begin conditions.
  if ((ret==0); then
  ##do something
  </code></pre>
  <p>instead of this:
  <code>firstchar=$(head -c 1 /tmp/file.txt)</code></p>
  <p>The statement <code>$?</code> is checking for the last command run <code>firstchar</code> instead of <code>tool ...</code></p>
  <p>How can I make the conditional statement check the status of this command:
  <code>tool test --json |&amp; tee /tmp/file.txt</code></p>