Loading...

Display file tree

:heavy_exclamation_mark: This post is older than a year. Consider some information might not be accurate anymore. :heavy_exclamation_mark:

If you want to display a file structure of a folder and the tree command is not available, use sed to replace to create a tree structure based on the find output.

Following command was invoked on RHEL 7.1 (Red Hat Enterprise Linux).

tan@cinhtau:~$ find metrics -print | sed 's;[^/]*/;|---;g;s;---|; |;g'
metrics
|---s01
| |---mbean-ws-endpoint.xml
| |---mbean.xml
| |---mbean-security.xml
|---mbean-os.xml
|---s04
| |---mbean-ws-endpoint_v2.xml
| |---mbean-ejb.xml
| |---mbean-endpoint.xml
|---mbean-memory.xml
|---mbean-http.xml
|---mbean-transactions.xml
|---mbean-datasource.xml
Please remember the terms for blog comments.