TIL How to check number of bash arguments ?

Written on 26 July 2016

The way to find out number of arguments bash script

echo Number of arguments are "${#@}"  

Why it right ?

${#varname} is length of variable. So @ is array of argument.
just save echo ${#@} to a file name test.sh then hit bash test.sh

The way to know number of args more simple is:

echo Number of arguments are "$#"  

Wonder know why ?

Read this post about The meaning of special dollar sign shell variables