2022-02-14 03:22:51 +01:00
|
|
|
---
|
|
|
|
title: format
|
|
|
|
layout: command
|
2022-03-04 13:10:09 +01:00
|
|
|
version: 0.59.1
|
2022-02-14 03:22:51 +01:00
|
|
|
---
|
2019-11-30 21:15:12 +01:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
Format columns into a string using a simple pattern.
|
2019-11-30 21:15:12 +01:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
## Signature
|
2019-11-30 21:15:12 +01:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
```> format (pattern)```
|
2019-11-30 21:15:12 +01:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
## Parameters
|
2019-11-30 21:15:12 +01:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
- `pattern`: the pattern to output. e.g.) "{foo}: {bar}"
|
2019-11-30 21:15:12 +01:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
## Examples
|
2019-11-30 21:15:12 +01:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
Print filenames with their sizes
|
2019-11-30 21:15:12 +01:00
|
|
|
```shell
|
2022-02-14 03:22:51 +01:00
|
|
|
> ls | format '{name}: {size}'
|
2019-11-30 21:15:12 +01:00
|
|
|
```
|
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
Print elements from some columns of a table
|
2019-11-30 21:15:12 +01:00
|
|
|
```shell
|
2022-02-14 03:22:51 +01:00
|
|
|
> echo [[col1, col2]; [v1, v2] [v3, v4]] | format '{col2}'
|
2020-06-23 20:21:47 +02:00
|
|
|
```
|