How to make “tree” output consistent on Linux
Posted on In QAI tried tree
on different Linux boxes to verify the files by diff
. However, I found the format can be a little bit different on different nodes.
For examples, the tree result could be
.
|-- test2
| |-- test4
| `-- test5
`-- test3
1 directory, 3 files
or
.
├── test2
│ ├── test4
│ └── test5
└── test3
1 directory, 3 files
How to make them consistent. Either one actually works for me.
You can set the charset that will be used by tree
:
tree --charset=ascii
or
tree --charset=utf-8
Tests on one Linux box:
$ tree
.
├── test2
│ ├── test4
│ └── test5
└── test3
1 directory, 3 files
$ tree --charset=ascii
.
|-- test2
| |-- test4
| `-- test5
`-- test3
1 directory, 3 files
The tree --charset=ascii
method should be more portable to be shown correctly on a wider range of devices.