Home Explore Blog CI



nushell

commands/docs/drop_nth.md
d130db6adb5a99b51e5adce92793d046ebc09b3d8dbd9fdd00000003000007ff
---
title: drop nth
categories: |
  filters
version: 0.104.0
filters: |
  Drop the selected rows.
usage: |
  Drop the selected rows.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

# `drop nth` for [filters](/commands/categories/filters.md)

<div class='command-title'>Drop the selected rows.</div>

## Signature

```> drop nth {flags} (row number or row range) ...rest```

## Parameters

 -  `row number or row range`: The number of the row to drop or a range to drop consecutive rows.
 -  `...rest`: The number of the row to drop.


## Input/output types:

| input     | output       |
| --------- | ------------ |
| list\<any\> | list\<any\>    |
| range     | list\<number\> |
## Examples

Drop the first, second, and third row
```nu
> [sam,sarah,2,3,4,5] | drop nth 0 1 2
╭───┬───╮
│ 0 │ 3 │
│ 1 │ 4 │
│ 2 │ 5 │
╰───┴───╯

```

Drop the first, second, and third row
```nu
> [0,1,2,3,4,5] | drop nth 0 1 2
╭───┬───╮
│ 0 │ 3 │
│ 1 │ 4 │
│ 2 │ 5 │
╰───┴───╯

```

Drop rows 0 2 4
```nu
> [0,1,2,3,4,5] | drop nth 0 2 4
╭───┬───╮
│ 0 │ 1 │
│ 1 │ 3 │
│ 2 │ 5 │
╰───┴───╯

```

Drop rows 2 0 4
```nu
> [0,1,2,3,4,5] | drop nth 2 0 4
╭───┬───╮
│ 0 │ 1 │
│ 1 │ 3 │
│ 2 │ 5 │
╰───┴───╯

```

Drop range rows from second to fourth
```nu
> [first second third fourth fifth] | drop nth (1..3)
╭───┬───────╮
│ 0 │ first │
│ 1 │ fifth │
╰───┴───────╯

```

Drop all rows except first row
```nu
> [0,1,2,3,4,5] | drop nth 1..
╭───┬───╮
│ 0 │ 0 │
╰───┴───╯

```

Drop rows 3,4,5
```nu
> [0,1,2,3,4,5] | drop nth 3..
╭───┬───╮
│ 0 │ 0 │
│ 1 │ 1 │
│ 2 │ 2 │
╰───┴───╯

```

Chunks
a218f27a (1st chunk of `commands/docs/drop_nth.md`)
Title: drop nth
Summary
The `drop nth` command in Nushell is a filter used to drop specified rows from a list. It takes row numbers or ranges as input and removes those rows from the list. The examples show how to drop specific rows, ranges of rows, and all rows except the first one.