I am looking to find the last positional parameter. I know to find the number of parameters is $# which logically is the last but I need to find and use what is in the last positional parameter.
It would be like if $# = 5, I want to do $5.
I have tried to do something like $$# or ${$#} as guesses but can't get it.
Instances where I would need to use it is in an if statement or declaring it to another variable or with echo.
I hope that is clear. Thanks in advance.
You want ${!#}
, which combines the argument count with indirection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With