The last positional parameter in bash Found a way to do this in a single line. Works nicely. eval "last=\${$#}" Share this:TwitterFacebookLike this:Like Loading... Related
To get the REST of the parameters: eval “rest=”`for d in `seq 1 $[$# – 1]`; do echo -n \$$d ; done`”” LikeLike Reply
To get the REST of the parameters:
eval “rest=”`for d in `seq 1 $[$# – 1]`; do echo -n \$$d ; done`””
LikeLike
The following works better:
eval “last=\${$#}”
LikeLike
Crap. It’s the following that works better:
eval “last=${$#}”
LikeLike
$(echo $@ |cut -d -f $#)
LikeLike
last=$(echo $@ |cut -d -f $#)
LikeLike
function cu() { eval ‘lasta=$’$#’;’; echo $last; };cu a b c daaa
LikeLike
last=”${!#}”
LikeLike