The script below shows how you can get the first and last arguments passed to a script:
numArgs="$#"
echo "Number of args: $numArgs"
firstArg="$1"
echo "First arg: $firstArg"
lastArg="${!#}"
echo "Last arg: $lastArg"
Output:
$ ./myshell_script.sh a b c d e f
Number of args: 6
First arg: a
Last arg: f