W3cubDocs

/Nushell

bytes replace for bytes

Find and replace binary.

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

>0x[10AAFFAAFF] |bytes replace0x[10AA] 0x[FF]
Length:4 (0x4) bytes|printablewhitespaceascii_othernon_ascii
00000000:ffffaaff××××

Find and replace all occurrences of find binary

>0x[10AA10BB10] |bytes replace-a0x[10] 0x[A0]
Length:5 (0x5) bytes|printablewhitespaceascii_othernon_ascii
00000000:a0aaa0bba0×××××

Find and replace all occurrences of find binary in table

> [[ColAColBColC]; [0x[111213] 0x[141516] 0x[171819]]] |bytes replace-a0x[11] 0x[13] ColAColC
╭───┬──────────────┬──────────────┬──────────────╮
# │     ColA     │     ColB     │     ColC     │
├───┼──────────────┼──────────────┼──────────────┤
0 [19, 18, 19]  [20, 21, 22]  [23, 24, 25] 
╰───┴──────────────┴──────────────┴──────────────╯

Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/bytes_replace.html