Unix $# statement Unix $# statement unix unix

Unix $# statement


The shell variable # is the number of arguments to your script. You can access them as $1, $2 and so on.


It evaluates to the number of command-line arguments passed to the script.

The best place to look to discover this kind of thing is the Bash manual. And in this particular case, you're interested in the section on special parameters. (oops, this is ksh, not Bash).


$# denotes the number of command line arguments supplied to the script. In your case it is checked whether exactly one argument was passed to it, otherwise some string explaining the usage is printed.