Home Explore Blog CI



nushell

commands/docs/bytes_starts-with.md
96140c88b1a8914551bc469bb78175c4ad4ea2d7a340d2b90000000300000470
---
title: bytes starts-with
categories: |
  bytes
version: 0.104.0
bytes: |
  Check if bytes starts with a pattern.
usage: |
  Check if bytes starts with a pattern.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

# `bytes starts-with` for [bytes](/commands/categories/bytes.md)

<div class='command-title'>Check if bytes starts with a pattern.</div>

## Signature

```> bytes starts-with {flags} (pattern) ...rest```

## Parameters

 -  `pattern`: The pattern to match.
 -  `...rest`: For a data structure input, check if bytes at the given cell paths start with the pattern.


## Input/output types:

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

Checks if binary starts with `0x[1F FF AA]`
```nu
> 0x[1F FF AA AA] | bytes starts-with 0x[1F FF AA]
true
```

Checks if binary starts with `0x[1F]`
```nu
> 0x[1F FF AA AA] | bytes starts-with 0x[1F]
true
```

Checks if binary starts with `0x[1F]`
```nu
> 0x[1F FF AA AA] | bytes starts-with 0x[11]
false
```

Chunks
589095c1 (1st chunk of `commands/docs/bytes_starts-with.md`)
Title: bytes starts-with: Check if bytes starts with a pattern.
Summary
The `bytes starts-with` command in Nushell is used to check if a given binary data starts with a specified pattern. It accepts a binary as input and a pattern to match. It returns a boolean value indicating whether the binary starts with the pattern or a data structure with boolean values. The rest parameter can take cell paths to check bytes in a record or table.