Improve Article. Save Article. Like Article. Recommended Articles. Article Contributed By :. Easy Normal Medium Hard Expert. Writing code in comment? Please use ide. Load Comments. What's New. Active 8 years, 3 months ago. Viewed times. Is there a way on unix to print out the file structure, like Bootstrap's getting started page?
Improve this question. Add a comment. Active Oldest Votes. Take a look to tree command. Improve this answer. Gilles Quenot Gilles Quenot Sign up or log in Sign up using Google. This avoids the need to switch to a particular directory before running the command.
You can also use the combination of find and awk commands to print the directory tree. For details, please refer to " How to print a multilevel tree directory structure using the linux find and awk combined commands ". The best answer is, of course, tree. But, to improve on other answers that rely on grepping the output of ls -R , here is a shell script that uses awk to print a tree of subdirectories.
First, an example of output:. The code gives better-looking results than other solutions because in a tree of subdirectories, the decorations in any branch depend on the branches below it. Hence, we need to process the output of ls -R in reverse order, from the last line to the first.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Linux command to print directory structure in the form of a tree Ask Question. Asked 11 years, 5 months ago. Active 3 months ago. Viewed k times. Just run find.
Or find. If you want to have output with spaces, as in the question, use it with this "find prettifier" script: find. Shouldn't such questions get migrated to SuperUser rather than closed? The tags seem to be right. The policy of closing questions without migrating is harmful to both stackoverflow and human knowledge in general. In the last 3 days, every single questions I googled and came across was closed for similar reasoning, and no more activity was able to happen. This means no one can update it, no one can give a better answer, and it makes stackoverflow look shortsighted or elitist.
Stackoverflow should consider requiring a migration when a topic is found to have these conditions. I agree with NickYeates I am here in late September of still finding answers to this same question. Think long term when we design these question and answer policies! Show 2 more comments.
Active Oldest Votes. Remove -d to display also files.
0コメント