开发者

How can I access command line arguments indexed from the end?

开发者 https://www.devze.com 2023-02-14 09:23 出处:网络
How can I get second argument from the end of argument开发者_如何学运维s line in bash?To print the second last argument use:

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

精彩评论

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