开发者

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}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜