Skip to main content
Version: v1.5.0

head

Operator

head copy leading values of input sequence

Synopsis

head [ n ]

Description

The head operator copies the first n values from its input to its output and ends the sequence thereafter. n must be an integer.

Examples

Grab first two values of arbitrary sequence

echo '1 "foo" [1,2,3]' | zq -z 'head 2' -

=>

1
"foo"

Grab the first record of a record sequence

echo '{a:"hello"}{b:"world"}' | zq -z head -

=>

{a:"hello"}