title: How to remove the last line from a variable in bash or sh?
body: <p>I have a variable that has few lines. I would like to remove the last line from the contents of the variable. I searched the internet but all the links talk about removing the last line from a file.
  Here is the content of my variable</p>
  
  <pre><code>$echo $var
  $select key from table_test
  UNION ALL
  select fob from table_test
  UNION ALL
  select cal from table_test
  UNION ALL
  select rot from table_test
  UNION ALL
  $
  </code></pre>
  
  <p>I would like to get rid of UNION ALL appearing in the last line alone.</p>