Do you need to pick up the last parameter $1
, $2
...
from the parameter list [the "command line"-JP ]?
It looks like eval \$$#
would do it:
eval | $ |
---|
except for a small problem with sh argument syntax:
$set m n o p q r s t u v w x
$echo $11
m1
$11
means ${1}1
, and not ${11}
.
Trying ${11}
directly gives bad substitution
.
The only reliable way to get at the last parameter is to use something like
for i do last="$i"; done
[That for loop assigns each parameter to the shell variable named
last;
after the loop ends, $last
will have the last parameter.
Also, note that you won't need this trick on all sh-like shells.
The Korn shell and bash understand ${11}
. -JP ]
- in comp.unix.questions on Usenet, 15 January 1990