title: access last but element of bash array
body: <p>I can access all element of an array like so:</p>
  
  <pre><code>echo ${myarray[@]}
  </code></pre>
  
  <p>and the number of elements:</p>
  
  <pre><code>echo ${#myarray[@]}
  </code></pre>
  
  <p>and I can get the nth element by doing:</p>
  
  <pre><code>echo ${myarray[@]:(-1)}
  </code></pre>
  
  <p>however I try the following to get the n-1th array element:</p>
  
  <pre><code>echo ${myarray[@]:(-2)}
  </code></pre>
  
  <p>but I end up with the last two elements. How do I only obtain the last but one element?</p>