Open Metric
Science, Fiction and Me

Today I Learned

List All Folders in Linux or Mac

To list all folders, ls provides an option -d. Here is an example.

ls -ld */

The output is

drwxr-xr-x  44 doe  staff  1496 Jun  7 20:47 box-folder/
drwxr-xr-x  73 doe  staff  2482 Jun 23 17:16 another-folder/
drwxr-xr-x  60 doe  staff  2040 Jul  5 15:18 fake-folder-or-not/

In some special cases, a folder might start with -. ls -d -- */ solves the problem. Here -- means the end of the options for ls.

Another choice is tree.

tree -d .

which provides a output of the structures

.
├── box-folder-2
│   ├── export
│   │   └── allcomplex
│   └── fofomegak
│       └── export
├── export
│   └── unstable-regions
├── box-folder
└── two-beams
    └── export-np

A Random #TIL# for You


Most technical TILs will be updated at datumorphism.leima.is/til

By OctoMiao

Last updated