COUNT(1)

✨ COUNT πŸ’… (fish-shell manual, bestie edition)

okay so you're here for count from the fish-shell manual β€” periodt, let's go πŸŽ€


🌸 NAME 🌸

count β€” literally just counts how many elements are in a list, that's the whole gig πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

count STRING1 STRING2 ...
COMMAND | count
count [...] < FILE

✨ DESCRIPTION ✨

okay so count prints the number of arguments that were passed to it, plus the number of newlines that got passed to it via stdin. that's it, that's the vibe 🫢

most of the time you're using this to find out how many elements an environment variable list contains, or how many lines there are in a text file. very demure, very useful.

🚨 heads up bestie: count does not accept any options. not even -h or --help. it's giving "no thoughts, head empty, just numbers" β€” do not try it, it will not slay 😭

here's the exit status tea β˜•: 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. so no args = sad girl hours, one arg = we're so back πŸ’…

also, note that, like wc -l, reading from stdin counts newlines, so echo -n foo | count will print 0. yes really. no newline, no count, no cap 🌈


πŸŽ€ 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

see? iconic. every single one of these is a main character move πŸ‘‘


fish-shell developers 🐟


okay that's the whole page, bestie β€” go forth and count things πŸ¦‹πŸ’œ

sign-off szn: this was count from fish-shell, version 4.9, dated Sep 08, 2026 β€” noting it here in the cute lil footer way instead of pasting the boring footer line, iykyk πŸŽ€βœ¨πŸ”₯

πŸ“¦ where this page comes from
  • arch rolling: fish 4.9.3-1 Β· GPL-2.0-only AND BSD-3-Clause AND ISC AND MIT AND PSF-2.0
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms