title: How to get the second last argument from shell script?
body: <p>I want to get the second last item given to a shell program. Currently I do it like this:</p>
  
  <pre><code>file1_tmp="${@: -2}"
  oldIFS=$IFS
  IFS=" "
  count=0
  for value in $file1; do
    if [[ count -e 0 ]]; then
      file1=$value
    fi
      count=1
  done
  oldIFS=$IFS 
  </code></pre>
  
  <p>I'm sure that there is a much easier way to do this. So how can I get the second last argument from a shell script input in as few lines as possible?</p>