2005-09-20 21:31:55 +08:00
|
|
|
|
|
|
|
\section count count - Count the number of elements of an array
|
|
|
|
|
|
|
|
\subsection count-synopsis Synopsis
|
|
|
|
<tt>count $VARIABLE</tt>
|
|
|
|
|
|
|
|
\subsection count-description Description
|
|
|
|
|
2005-10-08 17:33:10 +08:00
|
|
|
<tt>count</tt> returns the number of arguments that were passed to
|
2005-09-20 21:31:55 +08:00
|
|
|
it. This is usually used to find out how many elements an environment
|
|
|
|
variable array contains, but this is not the only potential usage for
|
|
|
|
the count command.
|
|
|
|
|
|
|
|
The count command does not accept any options, not even '-h'. This way
|
|
|
|
the user does not have to worry about an array containing elements
|
|
|
|
such as dashes. \c fish performs a special check when invoking the
|
|
|
|
count program, and if the user uses a help option, this help page is
|
|
|
|
displayed, but if a help option is contained inside of a variable or
|
2005-12-07 23:57:17 +08:00
|
|
|
is the result of expansion, it will be passed on to the count program.
|
2005-09-20 21:31:55 +08:00
|
|
|
|
|
|
|
\subsection count-example Example
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
count $PATH
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
returns the number of directories in the users PATH variable.
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
count *.txt
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
returns the number of files in the current working directory ending with the suffix '.txt'.
|