0xf

日記だよ

ツリー型の階層構造をテキストで表現したいとき、ディレクトリ構成を入れ子で作って tree コマンドで出力する習慣がある

こういう感じ

$ mkdir -p {sample/{foo,bar},prod/app/{a,b}}
$ tree .
.
├── prod
│   └── app
│       ├── a
│       └── b
└── sample
    ├── bar
    └── foo

テーブルは node の console.table を使っている。ブログだと崩れちゃうので頻度は高くはない。

$ node
> console.table([{"a":1}, {"a": 2, "b":2}])
┌─────────┬───┬───┐
│ (index) │ a │ b │
├─────────┼───┼───┤
│ 01 │   │
│ 122 │
└─────────┴───┴───┘

CSV形式で出力できる場合であれば column -t などを使う。

$ echo "a,b,1000,hoge,fuga\nd,e,10,aaaaaaa,hage" | cut -d"," -f 1,2,3,5 | column -s, -t
a  b  1000  fuga
d  e  10    hage