Skip to main content
Version: v1.13.0

tail

Operator​

  tail — copy trailing values of input sequence

Synopsis​

tail [ <expr> ]

Description​

The tail operator copies the last n values, evaluated from <expr>, from its input to its output and ends the sequence thereafter. <expr> must evaluate to a positive integer at compile time.

Examples​

Grab last two values of arbitrary sequence

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

=>

"foo"
[1,2,3]

Grab last two values of arbitrary sequence, using a different representation of two

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

=>

"foo"
[1,2,3]

Grab the last record of a record sequence

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

=>

{b:"world"}