Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash parameter count

# use $#

# say if you are expecting exactly 2 parameters
# -ne is bash's way of saying not equal
if [[ "$#" -ne 2 ]]; then
	echo "this script needs exactly 2 parameters"
    exit 1
 fi
 
PREVIOUS NEXT
Tagged: #bash #parameter #count
ADD COMMENT
Topic
Name
2+5 =