bash how to print the directory structure in linux

# Process:
1. Install the tree package with your favorite linux/unix installer, e.g.
	sudo apt-get install tree	# Using apt-get installer
    brew install tree			# Using brew installer
2. Run tree to see directory structure, e.g.:
	tree /directory/to/visualize/

# Note, you can specify the depth you want to visualize with the -L flag
# 	and you can display only directories with the -d flag, e.g.:
	tree -L 1 # Print the directories in the current directory
    tree -L 2 # Print current and subdirectories and files
    tree -L 2 -d # Print current and subdirectories

# Note, if you use tree a lot, using the following aliases can save you 
# some time:
	alias tree1='tree -L 1'
    alias tree2='tree -L 2'
    alias tree3='tree -L 3'

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source