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.
精彩评论