In my /bin/sh
script, I need to pass an indeterminate number of positional parameters, and get the last one (assign the last one to variable $LAST
) and then remove this last argument from $@
For example, I call my script with 4 arguments:
./myscript.sh AAA BBB CCC DDD
And inside my script, I need to echo the following:
echo $LAST
DDD
echo $@
AAA BBB CCC
How can I achieve this ?