title: How to exit if a command failed?
body: <p>I am a noob in shell-scripting. I want to print a message and exit my script if a command fails. I've tried:</p>
  
  <pre><code>my_command &amp;&amp; (echo 'my_command failed; exit)
  </code></pre>
  
  <p>but it does not work. It keeps executing the instructions following this line in the script. I'm using Ubuntu and bash.</p>