How to make "tree" output consistent on Linux

I 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.

asked Oct 8, 2015 by anonymous

1 Answer

 
Best answer

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.

answered Oct 8, 2015 by Eric Z Ma (44,280 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...