开发者

How do I find the last argument being passed INTO a script from $@?

#!/bin/bash 

/home/someDir/myServer $@

#arguments go as follow: ./se开发者_JS百科rver IP SERVICE PORT

port = $@ ?

echo "your port "$port

This IS NOT what I'm looking for: last_arg="${!#}"


I think ${@: -1:1} (the space is mandatory, otherwise it gets confused and thinks you're using defaulting) will do it; the slice syntax, unlike subscripts, allows negative numbers to index from the end of the array.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜