Getting the last argument passed to a shell script

Thomas picture Thomas · Dec 6, 2009 · Viewed 128.7k times · Source

$1 is the first argument.
$@ is all of them.

How can I find the last argument passed to a shell script?

Answer

This is Bash-only:

echo "${@: -1}"