I want to get the second last item given to a shell program. Currently I do it like this:
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
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?