Home Explore Blog CI



nushell

commands/docs/format_pattern.md
eee342c16ad93b48ee78b16d4324da0aa248c50c15e2372c000000030000043b
---
title: format pattern
categories: |
  strings
version: 0.104.0
strings: |
  Format columns into a string using a simple pattern.
usage: |
  Format columns into a string using a simple pattern.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

# `format pattern` for [strings](/commands/categories/strings.md)

<div class='command-title'>Format columns into a string using a simple pattern.</div>

## Signature

```> format pattern {flags} (pattern)```

## Parameters

 -  `pattern`: The pattern to output. e.g.) "{foo}: {bar}".


## Input/output types:

| input  | output       |
| ------ | ------------ |
| record | any          |
| table  | list\<string\> |
## Examples

Print filenames with their sizes
```nu
> ls | format pattern '{name}: {size}'

```

Print elements from some columns of a table
```nu
> [[col1, col2]; [v1, v2] [v3, v4]] | format pattern '{col2}'
╭───┬────╮
│ 0 │ v2 │
│ 1 │ v4 │
╰───┴────╯

```

Chunks
907d984a (1st chunk of `commands/docs/format_pattern.md`)
Title: format pattern
Summary
Formats columns into a string using a specified pattern. It accepts a record or a table as input and outputs either a string or a list of strings depending on the input type. The pattern parameter defines how the columns are arranged in the output string.