Skip to content
The Bash Insectarium

/static/insetario/en/inseto/param-tamanho/

Menu

BSH-008 · Parameters

${#var}

The value's length, counted in characters, with no helper process.

The hash before the name measures instead of expanding: ${#var} is the number of characters in the value — characters, not bytes, according to the locale.

With @ or *, the count changes target: ${#@} is how many arguments the script received — same as $#. On arrays, ${#colmeia[@]} counts the elements.

$ especie="Apis mellifera"
$ echo ${#especie}
14
Fourteen characters, measured by the shell itself.