2018-12-16 17:39:33 -08:00
count - count the number of elements of an array
2019-01-02 20:10:47 -08:00
================================================
2018-12-16 17:39:33 -08:00
2018-12-17 17:58:24 -08:00
Synopsis
--------
2018-12-16 13:08:41 -08:00
count $VARIABLE
2018-12-17 17:58:24 -08:00
2018-12-16 13:08:41 -08:00
2018-12-18 18:44:30 -08:00
Description
2019-01-02 20:10:47 -08:00
-----------
2018-12-16 13:08:41 -08:00
2018-12-19 12:02:45 -08:00
`` count `` prints the number of arguments that were passed to it. This is usually used to find out how many elements an environment variable array contains.
2018-12-16 13:08:41 -08:00
2018-12-19 12:02:45 -08:00
`` count `` does not accept any options, not even `` -h `` or `` --help `` .
2018-12-16 13:08:41 -08:00
2018-12-19 12:02:45 -08:00
`` count `` exits with a non-zero exit status if no arguments were passed to it, and with zero if at least one argument was passed.
2018-12-16 13:08:41 -08:00
2018-12-18 18:44:30 -08:00
Example
2019-01-02 20:10:47 -08:00
-------
2018-12-16 13:08:41 -08:00
2018-12-18 19:14:04 -08:00
::
count $PATH
# Returns the number of directories in the users PATH variable.
count *.txt
# Returns the number of files in the current working directory ending with the suffix '.txt'.