On Sun, May 06, 2012 at 01:24:09PM -0600, Bill Gradwohl wrote:
> set -- "The cat " "ate the " "canary"
> echo $#
> x=$#
> declare string
> string="${*%${$#}}"
What the bloody hell is that supposed to DO?
> I expected all of them to work.
What is "work"?
Seriously, tell us what you THINK it is supposed to do. Better yet,
simply tell us what you WANT to do, and do not write any code, and we
will tell you how to do it. Or we will tell you that it is not possible.
Are you trying to print the Nth positional parameter, where N is an
integer stored in some other variable? Then do this:
set -- "the cat " "ate the " "canary"
n=3
echo "${!n}"
Or use an actual array:
array=("$@")
n=3
echo "${array[n]}"