How can I access command line arguments indexed from the end?
How can I get second argument from the end of argument开发者_如何学运维s line in bash?
To print the second last argument use:
echo "${@:(-2):1}"
one way in Bash
set -- ${@:(-2)}
echo $1
or simply
echo ${@:(-2):1}
精彩评论