The first time I saw someone type in the command ‘tree’ and put the directory into a tree structure I thought it was amazing. Like this one:

The reason for the exclamation is that I’ve always looked at file directories this way, as in the following picture:

Is such a comparison a judgment? Install using walk up ~

Method 1: Directly install the tree

brew install tree
Copy the code

Brew: What is brew?

Answer: brew, also called Homebrew, is a software package management tool on Mac OSX, which can easily install or uninstall software in Mac. Easy to install on MAC, in one sentence:

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
Copy the code

Write the tree command to ~/.bash_profile

Vim ~ # open the ~ /. The following documents /. Following # copy the code below to ~ /. In the following file alias tree = "find. - print | sed -e 's; [^ /] * /. | _____; g; s; ____ |; |; g'"Copy the code

Press ESC to exit the write mode, then enter :wq to write and push out

Tree command line arguments:

  • -a Displays all files and directories.
  • -a Displays tree graphs using ASNI drawing characters instead of ASCII character combinations.
  • -c Add colors to the file and directory lists to distinguish different types.
  • -d Displays the directory name instead of the content.
  • -d Lists the change time of files or directories.
  • -f Displays complete relative path names before each file or directory.
  • – F in the executable files, directories, Socket, symbolic links, pipeline name names, each with “*”, “/”, “=”, “@”, “|”.
  • -g Lists the group name of a file or directory. If no group name exists, the group identification code is displayed.
  • -i Does not list file or directory names in ladder form.
  • -i Does not display file or directory names that match the template style.
  • -l If a directory is a symbolic link, the directory to which the link points is directly listed.
  • -n Does not color file and directory lists.
  • -n Directly lists file and directory names, including control characters.
  • -p Lists permission labels.
  • -p Displays only file or directory names that match the template style.
  • – q with “?” The sign replaces the control character to list file and directory names.
  • -s Lists file or directory sizes.
  • -t Sorts files and directories by change time.
  • -u Lists the name of the owner of a file or directory. If no corresponding name exists, the user id is displayed.
  • -x limits the search scope to the current file system. If some subdirectories in a specified directory are stored on another file system, the subdirectories are excluded from the search scope.

Tree –help is also available