Number of arguments is in variable $#, example is script numarg.sh
#!/bin/bash
echo "number of arguments: $#"
Executing script:
$ ./numarg.sh arg1 arg2 arg3
Number of arguments: 3
Variable $# doesn't count script name, only arguments.
Arguments are stored in variables $1, $2... or in $@ as array.
No comments:
Post a Comment