2022-02-14 02:22:51 +00:00
|
|
|
---
|
|
|
|
title: keep
|
|
|
|
layout: command
|
|
|
|
version: 0.59.0
|
|
|
|
---
|
2021-05-30 00:57:04 +00:00
|
|
|
|
2022-02-14 02:22:51 +00:00
|
|
|
Keep the first n elements of the input.
|
|
|
|
|
|
|
|
## Signature
|
2021-05-30 00:57:04 +00:00
|
|
|
|
2022-02-14 02:22:51 +00:00
|
|
|
```> keep (n)```
|
2021-05-30 00:57:04 +00:00
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
2022-02-14 02:22:51 +00:00
|
|
|
- `n`: the number of elements to keep
|
2021-05-30 00:57:04 +00:00
|
|
|
|
|
|
|
## Examples
|
2022-02-14 02:22:51 +00:00
|
|
|
|
|
|
|
Keep two elements
|
2021-05-30 00:57:04 +00:00
|
|
|
```shell
|
2022-02-14 02:22:51 +00:00
|
|
|
> echo [[editions]; [2015] [2018] [2021]] | keep 2
|
|
|
|
```
|
2021-05-30 00:57:04 +00:00
|
|
|
|
2022-02-14 02:22:51 +00:00
|
|
|
Keep the first value
|
2021-05-30 00:57:04 +00:00
|
|
|
```shell
|
2022-02-14 02:22:51 +00:00
|
|
|
> echo [2 4 6 8] | keep
|
|
|
|
```
|
2021-05-30 00:57:04 +00:00
|
|
|
|