joshtronic

in Command-line Interface

Show hidden files with tree

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