2
#!/bin/bash 

/home/someDir/myServer $@

#arguments go as follow: ./server IP SERVICE PORT

port = $@ ?

echo "your port "$port

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

2
  • more information please?
    – geekosaur
    Commented Jun 21, 2011 at 16:42
  • If you know you're supposed to get 3 args, why not port=$3? Commented Jun 21, 2011 at 17:07

1 Answer 1

6

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.