James James
James James

Reputation: 51

Equivalent to 'Tree' command but not recursive?

I'm looking for an alternative to 'Tree' command in Linux however I want it to be based on NOT a recursive algorithm.

Tree command is based on a recursive algorithm, as seen from its description:

Tree is a recursive directory listing program that produces a depth indented listing of files.

Is there another way which is not recursive?

Thank you!

Upvotes: 0

Views: 3154

Answers (2)

enharmonic
enharmonic

Reputation: 2090

I think you might be looking for the -d flag which only shows the directory tree (with no files). From the tree man page:

-d

List directories only.

tree -d /path/to/dir

Upvotes: 0

Trung
Trung

Reputation: 325

With tree -L <level> you can specify how many level directories deep to descend. In your case it would be:

tree -L 1

Upvotes: 4

Related Questions