2019-11-14 22:59:39 +01:00
|
|
|
# pivot
|
|
|
|
|
|
|
|
Pivots the table contents so rows become columns and columns become rows.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
2020-06-23 20:21:47 +02:00
|
|
|
```shell
|
2019-11-14 22:59:39 +01:00
|
|
|
> ls docs
|
2020-06-23 20:21:47 +02:00
|
|
|
───┬────────────────────┬──────┬────────┬─────────────
|
|
|
|
# │ name │ type │ size │ modified
|
|
|
|
───┼────────────────────┼──────┼────────┼─────────────
|
|
|
|
0 │ docs/commands │ Dir │ 2.7 KB │ 53 mins ago
|
|
|
|
1 │ docs/docker.md │ File │ 7.0 KB │ 40 mins ago
|
|
|
|
2 │ docs/philosophy.md │ File │ 912 B │ 54 mins ago
|
|
|
|
───┴────────────────────┴──────┴────────┴─────────────
|
|
|
|
```
|
2019-11-14 22:59:39 +01:00
|
|
|
|
2020-06-23 20:21:47 +02:00
|
|
|
```shell
|
2019-11-14 22:59:39 +01:00
|
|
|
> ls docs | pivot
|
2020-06-23 20:21:47 +02:00
|
|
|
───┬──────────┬───────────────┬────────────────┬────────────────────
|
2019-11-14 22:59:39 +01:00
|
|
|
# │ Column0 │ Column1 │ Column2 │ Column3
|
|
|
|
───┼──────────┼───────────────┼────────────────┼────────────────────
|
|
|
|
0 │ name │ docs/commands │ docs/docker.md │ docs/philosophy.md
|
2020-06-23 20:21:47 +02:00
|
|
|
1 │ type │ Dir │ File │ File
|
|
|
|
2 │ size │ 2.7 KB │ 7.0 KB │ 912 B
|
|
|
|
3 │ modified │ 53 mins ago │ 40 mins ago │ 55 mins ago
|
|
|
|
───┴──────────┴───────────────┴────────────────┴────────────────────
|
2019-11-14 22:59:39 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
Use `--header-row` to treat the first row as column names:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
> ls docs | pivot --header-row
|
2020-06-23 20:21:47 +02:00
|
|
|
───┬───────────────┬────────────────┬────────────────────
|
2019-11-14 22:59:39 +01:00
|
|
|
# │ docs/commands │ docs/docker.md │ docs/philosophy.md
|
|
|
|
───┼───────────────┼────────────────┼────────────────────
|
2020-06-23 20:21:47 +02:00
|
|
|
0 │ Dir │ File │ File
|
|
|
|
1 │ 2.7 KB │ 7.0 KB │ 912 B
|
|
|
|
2 │ 53 mins ago │ 40 mins ago │ 55 mins ago
|
|
|
|
───┴───────────────┴────────────────┴────────────────────
|
2019-11-14 22:59:39 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
Use `--ignore-titles` to prevent pivoting the column names into values:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
> ls docs | pivot --ignore-titles
|
2020-06-23 20:21:47 +02:00
|
|
|
───┬───────────────┬────────────────┬────────────────────
|
2019-11-14 22:59:39 +01:00
|
|
|
# │ Column0 │ Column1 │ Column2
|
|
|
|
───┼───────────────┼────────────────┼────────────────────
|
|
|
|
0 │ docs/commands │ docs/docker.md │ docs/philosophy.md
|
2020-06-23 20:21:47 +02:00
|
|
|
1 │ Dir │ File │ File
|
|
|
|
2 │ 2.7 KB │ 7.0 KB │ 912 B
|
|
|
|
3 │ 54 mins ago │ 41 mins ago │ 56 mins ago
|
|
|
|
───┴───────────────┴────────────────┴────────────────────
|
2019-11-14 22:59:39 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
Additional arguments are used as column names:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
> ls docs | pivot foo bar baz
|
2020-06-23 20:21:47 +02:00
|
|
|
───┬──────────┬───────────────┬────────────────┬────────────────────
|
2019-11-14 22:59:39 +01:00
|
|
|
# │ foo │ bar │ baz │ Column3
|
|
|
|
───┼──────────┼───────────────┼────────────────┼────────────────────
|
|
|
|
0 │ name │ docs/commands │ docs/docker.md │ docs/philosophy.md
|
2020-06-23 20:21:47 +02:00
|
|
|
1 │ type │ Dir │ File │ File
|
|
|
|
2 │ size │ 2.7 KB │ 7.0 KB │ 912 B
|
|
|
|
3 │ modified │ 55 mins ago │ 41 mins ago │ 56 mins ago
|
|
|
|
───┴──────────┴───────────────┴────────────────┴────────────────────
|
2019-11-14 22:59:39 +01:00
|
|
|
```
|