A quick way to reference the last parameter given to your shell script: ${!#} So call myscript.sh a b c d e If you echo ${!#} you'd get "e"
0
0
1
0
0