When you generate a tree for a large directory base with innumerable sub-directories and associated files, with -a option, often you get a large file with thousands of lines. While traversing the tree depicted within this file, it often becomes difficult to keep track of which directory you are in at any given point in time, as you descend deeper into the tree. As you scroll down the file from within a text editor like vi, you can lose track of the outer level directory labels.

So my question is, is there a way to overcome this issue? Is it possible at all to get some kind of perspective of the outer level directory labels, as you descend deeper into the tree?


The tree utility on Linux has a -f option that lists each directory entry with its relative pathname:

$ tree -f ufw
├── ufw/after6.rules
├── ufw/after.init
├── ufw/after.rules
├── ufw/applications.d
│   ├── ufw/applications.d/cups
│   ├── ufw/applications.d/openssh-server
│   └── ufw/applications.d/postfix
├── ufw/before6.rules
├── ufw/before.init
├── ufw/before.rules
├── ufw/sysctl.conf
├── ufw/ufw.conf
├── ufw/user6.rules
└── ufw/user.rules

1 directory, 13 files

This would allow you to always know the exact pathname for each entry, relative to the top-level directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.