Home Explore Blog CI



nushell

1st chunk of `commands/docs/bytes_replace.md`
a9da24672e59a56b44a7a27b6b628b46870be242db10b3ba0000000100000843
---
title: bytes replace
categories: |
  bytes
version: 0.104.0
bytes: |
  Find and replace binary.
usage: |
  Find and replace binary.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

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

<div class='command-title'>Find and replace binary.</div>

## Signature

```> bytes replace {flags} (find) (replace) ...rest```

## Flags

 -  `--all, -a`: replace all occurrences of find binary

## Parameters

 -  `find`: The pattern to find.
 -  `replace`: The replacement pattern.
 -  `...rest`: For a data structure input, replace bytes in data at the given cell paths.


## Input/output types:

| input  | output |
| ------ | ------ |
| binary | binary |
| record | record |
| table  | table  |
## Examples

Find and replace contents
```nu
> 0x[10 AA FF AA FF] | bytes replace 0x[10 AA] 0x[FF]
Length: 4 (0x4) bytes | printable whitespace ascii_other non_ascii
00000000:   ff ff aa ff                                          ××××

```

Find and replace all occurrences of find binary
```nu
> 0x[10 AA 10 BB 10] | bytes replace --all 0x[10] 0x[A0]
Length: 5 (0x5) bytes | printable whitespace ascii_other non_ascii
00000000:   a0 aa a0 bb  a0                                      ×××××

```

Find and replace all occurrences of find binary in table
```nu
> [[ColA ColB ColC]; [0x[11 12 13] 0x[14 15 16] 0x[17 18 19]]] | bytes replace --all 0x[11] 0x[13] ColA ColC
╭───┬──────────────┬──────────────┬──────────────╮
│ # │     ColA     │     ColB     │     ColC     │
├───┼──────────────┼──────────────┼──────────────┤
│ 0 │ [19, 18, 19] │ [20, 21, 22] │ [23, 24, 25] │
╰───┴──────────────┴──────────────┴──────────────╯

```

Title: bytes replace
Summary
The `bytes replace` command in Nushell is used to find and replace binary data. It can operate on binary data directly, or on records and tables, replacing bytes at specified cell paths. The command supports replacing all occurrences of the 'find' binary with the 'replace' binary using the `--all` flag.