Spec-Zone.ru › Nushell

format pattern for strings

Format columns into a string using a simple pattern.

Signature

> format pattern {flags} (pattern)

Parameters

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

Input/output types:

input output
table list<string>
record any

Examples

Print filenames with their sizes

> ls | format pattern '{name}: {size}'

Print elements from some columns of a table

> [[col1, col2]; [v1, v2] [v3, v4]] | format pattern '{col2}'
╭───┬────╮
│ 0 │ v2 │
│ 1 │ v4 │
╰───┴────╯

Escape braces by repeating them

> {start: 3, end: 5} | format pattern 'if {start} < {end} {{ "correct" }} else {{ "incorrect" }}'
if 3 < 5 { "correct" } else { "incorrect" }

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

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API