Show hidden files with tree by Josh Sherman

0
30

The tree command is one of my favorites. As the name of the command suggests, it simply lists the contents of a directory in a tree-like format.

Think of it like ls *which outputs the contents of each directory, but instead of a flat list, the files are shown with a cool little ASCII tree as such:

/tmp/tree
% tree
.
├── one
│   ├── file1.txt
│   ├── file2.txt
│   └── file3.txt
├── three
│   ├── file1.txt
│   ├── file2.txt
│   └── file3.txt
└── two
    ├── file1.txt
    ├── file2.txt
    └── file3.txt

3 directories, 9 files

While you can’t necessarily tell by looking at the output, there aren’t any hidden files being shown. Generally speaking, that’s not a bad thing, especially if you are using tree with noisy directory that has a ton of hidden files (like your home directory).

If you did want to display hidden files, all you need to do is pass in the -a
flag, and that will tell tree to show all files:

/tmp/tree
% tree -a
.
├── .hiddenFile1.txt
├── .hiddenFile2.txt
├── .hiddenFile3.txt
├── one
│   ├── file1.txt
│   ├── file2.txt
│   └── file3.txt
├── three
│   ├── file1.txt
│   ├── file2.txt
│   └── file3.txt
└── two
    ├── file1.txt
    ├── file2.txt
    └── file3.txt

3 directories, 12 files

Good stuff? Want more?

Weekly emails about technology, development, and sometimes sauerkraut.

100% Fresh, Grade A Content, Never Spam.

Source

LEAVE A REPLY

Please enter your comment!
Please enter your name here