special-parameter
Bash $# — argument count
Counts positional parameters excluding $0. Useful for checking whether required script arguments are present.
Formal Syntax & Structure
bash syntaxbash
$#Return Value
integer text
Number of positional parameters.
Working Example
Example Snippetbash
bash -c 'printf "name=%s count=%s\n" "$0" "$#"; printf "first=%s second=%s\n" "$1" "$2"' demo 'New York' report