count

Synopsis

any |> count

Description

count reads the whole input and gives the number of records as an int. The records are not held in memory. An empty input gives 0.

count counts file records before an effect and the records of an effect after it (stage 5a), for example the exec records of a program run.

Parameters

The command has no parameters.

Input and output

Form Input Output
default any int

Effect

Property Value
Category transform
Effect read
Reversibility read
Implementation builtin

Examples

Count the files of a project:

find "/home/user/project" |> count

Counting the lines of an empty file gives 0:

lines "/home/user/empty.txt" |> count

Count the results of a program run:

run ["git", "status", "--short"] cwd: "/home/user/project" |> count

Errors

Code Meaning Typical fix
E_TYPE the input is a single value, not records apply count to a stage that produces records

assert, summarize, group.

Source file on GitHub: docs/commands/count.md