mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-29 08:41:15 -03:00
Commit 0893134543 (Added .editorconfig file (#3332) (#3313),
2016-08-25) trimmed trailing whitespace for Markdown file (which do
have significant trailing whitespace) but ReStructuredText does not,
and none of our Markdown files cares about this, so let's clean up
whitespace always.
46 lines
1.3 KiB
ReStructuredText
46 lines
1.3 KiB
ReStructuredText
count - count the number of elements of a list
|
|
================================================
|
|
|
|
Synopsis
|
|
--------
|
|
|
|
.. synopsis::
|
|
|
|
count STRING1 STRING2 ...
|
|
COMMAND | count
|
|
count [...] < FILE
|
|
|
|
Description
|
|
-----------
|
|
|
|
``count`` prints the number of arguments that were passed to it, plus the number of newlines passed to it via stdin. This is usually used to find out how many elements an environment variable list contains, or how many lines there are in a text file.
|
|
|
|
``count`` does not accept any options, not even ``-h`` or ``--help``.
|
|
|
|
``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.
|
|
|
|
Note that, like ``wc -l``, reading from stdin counts newlines, so ``echo -n foo | count`` will print 0.
|
|
|
|
Example
|
|
-------
|
|
|
|
|
|
|
|
::
|
|
|
|
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'.
|
|
|
|
git ls-files --others --exclude-standard | count
|
|
# Returns the number of untracked files in a git repository
|
|
|
|
printf '%s\n' foo bar | count baz
|
|
# Returns 3 (2 lines from stdin plus 1 argument)
|
|
|
|
count < /etc/hosts
|
|
# Counts the number of entries in the hosts file
|