The number of arguments on the command line (not counting the script name itself) is automatically stored in the $# variable. For example:
contents of simple_script.bash:
Code:
#!/bin/bash
echo $#
exit 0
[me@host]$
chmod u+x ./simple_script.bash
[me@host]$
./simple_script.bash 1 2 3 4 5
5
[me@host]$