Home Explore Blog CI



nushell

commands/docs/enumerate.md
6107bfe96652f1dce3bb66f84c02f90fb26e67c3d34b5ab0000000030000034f
---
title: enumerate
categories: |
  filters
version: 0.104.0
filters: |
  Enumerate the elements in a stream.
usage: |
  Enumerate the elements in a stream.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

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

<div class='command-title'>Enumerate the elements in a stream.</div>

## Signature

```> enumerate {flags} ```


## Input/output types:

| input | output |
| ----- | ------ |
| any   | table  |
## Examples

Add an index to each element of a list
```nu
> [a, b, c] | enumerate
╭───┬──────╮
│ # │ item │
├───┼──────┤
│ 0 │ a    │
│ 1 │ b    │
│ 2 │ c    │
╰───┴──────╯

```

Chunks
5817333d (1st chunk of `commands/docs/enumerate.md`)
Title: enumerate
Summary
The `enumerate` command in Nushell is a filter that takes a stream of any type and adds an index to each element. This transformation results in a table where each row represents an element from the original stream, and the columns are '#' for the index and 'item' for the value of the element. The indexing starts from 0. This is useful for scenarios where you need to keep track of the position of each element within a stream, such as when iterating over a list and needing to access elements by their index. The command has no flags and simply takes the stream as input and outputs the enumerated table. For example, enumerating the list `[a, b, c]` would produce a table with rows `0 a`, `1 b`, and `2 c`, under the respective columns '#' and 'item'.