Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

bytes index-of for bytes

Returns start index of first occurrence of pattern in bytes, or -1 if no match.

Signature

> bytes index-of {flags} (pattern) ...rest

Flags

  • --all, -a: returns all matched index
  • --end, -e: search from the end of the binary

Parameters

  • pattern: The pattern to find index of.
  • ...rest: For a data structure input, find the indexes at the given cell paths.

Input/output types:

inputoutput
binaryany
tabletable
recordrecord

Examples

Returns index of pattern in bytes

>  0x[33 44 55 10 01 13 44 55] | bytes index-of 0x[44 55]
1

Returns index of pattern, search from end

>  0x[33 44 55 10 01 13 44 55] | bytes index-of --end 0x[44 55]
6

Returns all matched index

>  0x[33 44 55 10 01 33 44 33 44] | bytes index-of --all 0x[33 44]
╭───┬───╮
│ 0 │ 0 │
│ 1 │ 5 │
│ 2 │ 7 │
╰───┴───╯

Returns all matched index, searching from end

>  0x[33 44 55 10 01 33 44 33 44] | bytes index-of --all --end 0x[33 44]
╭───┬───╮
│ 0 │ 7 │
│ 1 │ 5 │
│ 2 │ 0 │
╰───┴───╯

Returns index of pattern for specific column

>  [[ColA ColB ColC]; [0x[11 12 13] 0x[14 15 16] 0x[17 18 19]]] | bytes index-of 0x[11] ColA ColC
╭───┬──────┬──────────────┬──────╮
│ # │ ColA │     ColB     │ ColC │
├───┼──────┼──────────────┼──────┤
│ 0 │    0 │ [20, 21, 22] │   -1 │
╰───┴──────┴──────────────┴──────╯