Home Explore Blog CI



nushell

commands/docs/bytes_at.md
e3ed7a5a675231bde16792e0bd68ce4367e7aa73f8ac66c50000000300000bcf
---
title: bytes at
categories: |
  bytes
version: 0.104.0
bytes: |
  Get bytes defined by a range.
usage: |
  Get bytes defined by a range.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

# `bytes at` for [bytes](/commands/categories/bytes.md)

<div class='command-title'>Get bytes defined by a range.</div>

## Signature

```> bytes at {flags} (range) ...rest```

## Parameters

 -  `range`: The range to get bytes.
 -  `...rest`: For a data structure input, get bytes from data at the given cell paths.


## Input/output types:

| input        | output       |
| ------------ | ------------ |
| binary       | binary       |
| list\<binary\> | list\<binary\> |
| record       | record       |
| table        | table        |
## Examples

Extract bytes starting from a specific index
```nu
> { data: 0x[33 44 55 10 01 13 10] } | bytes at 3.. data
╭──────┬─────────────────╮
│ data │ [16, 1, 19, 16] │
╰──────┴─────────────────╯
```

Slice out `0x[10 01 13]` from `0x[33 44 55 10 01 13]`
```nu
> 0x[33 44 55 10 01 13] | bytes at 3..5
Length: 3 (0x3) bytes | printable whitespace ascii_other non_ascii
00000000:   10 01 13                                             •••

```

Extract bytes from the start up to a specific index
```nu
> 0x[33 44 55 10 01 13 10] | bytes at ..4
Length: 5 (0x5) bytes | printable whitespace ascii_other non_ascii
00000000:   33 44 55 10  01                                      3DU••

```

Extract byte `0x[10]` using an exclusive end index
```nu
> 0x[33 44 55 10 01 13 10] | bytes at 3..<4
Length: 1 (0x1) bytes | printable whitespace ascii_other non_ascii
00000000:   10                                                   •

```

Extract bytes up to a negative index (inclusive)
```nu
> 0x[33 44 55 10 01 13 10] | bytes at ..-4
Length: 4 (0x4) bytes | printable whitespace ascii_other non_ascii
00000000:   33 44 55 10                                          3DU•

```

Slice bytes across multiple table columns
```nu
> [[ColA ColB ColC]; [0x[11 12 13] 0x[14 15 16] 0x[17 18 19]]] | bytes at 1.. ColB ColC
╭───┬──────────────┬──────────┬──────────╮
│ # │     ColA     │   ColB   │   ColC   │
├───┼──────────────┼──────────┼──────────┤
│ 0 │ [17, 18, 19] │ [21, 22] │ [24, 25] │
╰───┴──────────────┴──────────┴──────────╯

```

Extract the last three bytes using a negative start index
```nu
> 0x[33 44 55 10 01 13 10] | bytes at (-3)..
Length: 3 (0x3) bytes | printable whitespace ascii_other non_ascii
00000000:   01 13 10                                             •••

```

Chunks
04810fbd (1st chunk of `commands/docs/bytes_at.md`)
Title: bytes at
Summary
The `bytes at` command in Nushell allows you to extract a specific range of bytes from a binary value. It accepts a range as input and can be used on binary data directly, as well as within lists, records, and tables by specifying cell paths. The command supports various range specifications, including start/end indices (positive and negative), exclusive end indices, and open-ended ranges. The output is a new binary value containing the extracted bytes.