Home Explore Blog CI



nushell

1st chunk of `commands/docs/bytes_collect.md`
0b7031726e4623b89ec39f631d04778dc2a591d1c7b9e847000000010000053f
---
title: bytes collect
categories: |
  bytes
version: 0.104.0
bytes: |
  Concatenate multiple binary into a single binary, with an optional separator between each.
usage: |
  Concatenate multiple binary into a single binary, with an optional separator between each.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

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

<div class='command-title'>Concatenate multiple binary into a single binary, with an optional separator between each.</div>

## Signature

```> bytes collect {flags} (separator)```

## Parameters

 -  `separator`: Optional separator to use when creating binary.


## Input/output types:

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

Create a byte array from input
```nu
> [0x[11] 0x[13 15]] | bytes collect
Length: 3 (0x3) bytes | printable whitespace ascii_other non_ascii
00000000:   11 13 15                                             •••

```

Create a byte array from input with a separator
```nu
> [0x[11] 0x[33] 0x[44]] | bytes collect 0x[01]
Length: 5 (0x5) bytes | printable whitespace ascii_other non_ascii
00000000:   11 01 33 01  44                                      ••3•D

```

Title: bytes collect
Summary
The `bytes collect` command, found within the `bytes` category in Nushell, combines a list of binary values into a single binary value. An optional `separator` parameter (also a binary value) can be used to insert a delimiter between each of the original binary inputs during concatenation. The command accepts a `list<binary>` as input and produces a single `binary` value as output, effectively creating a larger binary blob from its components. The inclusion of a separator facilitates potential splitting of the concatenated data later, if required. Examples demonstrate constructing byte arrays from input lists, with and without separators. The resulting output includes the length of the concatenated binary and a hexadecimal representation for inspection and verification, enhancing data manipulation within Nushell.