bash get directory structure code example
Example: 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'