last
Synopsis
any |> last <count>
Description
last passes on the last count input records. The stage reads the whole
input and holds no more than count records at a time; when count is
larger than the record limit of the request and the input is longer than the
limit, the program stops with E_LIMIT.
The order, the header and the presentation hint of the stream are kept. An
input with fewer records than count passes on whole.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
count |
int |
required | Number of records to keep. |
Input and output
| Form | Input | Output |
|---|---|---|
| default | any |
same |
Effect
| Property | Value |
|---|---|
| Category | transform |
| Effect | read |
| Reversibility | read |
| Implementation | builtin |
Examples
Keep the last file of a listing:
find "/home/user/project" |> last 1
Show the last two lines of a log:
lines "/home/user/app.log" |> last 2
Keep all files when there are fewer than ten:
find "/home/user/project" |> last 10
Errors
| Code | Meaning | Typical fix |
|---|---|---|
E_MISSING_PARAM |
count is missing |
write a number after last |
E_INVALID_VALUE |
count is negative |
use 0 or a larger number |
E_LIMIT |
more records must be held than the limit allows | lower count or narrow the input |
Related
first, skip, sort.