True education is one tree shaking another tree, one cloud pushing another cloud, one soul awakening another soul. -- JaspersCopy the code

Tree Command description

Tree is a command that lists a recursive directory, graphically displaying the folder structure of a drive or path. It can generate a directory tree.

Tree Command installation

On both Windows and Linux, the tree command is unavailable on a MAC by default. You need to install the tree command first. The installation command is as follows:

brew install tree
Copy the code

Found that my new Mac does not have brew command installed, need to install Homebrew first.

Install Homebrew on a Mac

Homebrew installs something that Apple (or your Linux system) doesn’t have pre-installed but you need, command to install it as follows:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Copy the code

An error occurs during installation according to the command on the official website. The error message is as follows:

curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
Copy the code

I searched a lot of information on the Internet. Some people said it was because of the agent problem, while others said it was because of the Redis problem, but they couldn’t do it after trying. Finally, the solution was as follows: Reinstall Command line Tools and execute the installation command.

  1. Remove the old Command Line Tools
    • $ sudo rm -rf /Library/Developer/CommandLineTools
  2. Reinstall the Command Line Tools
    • $ xcode-select --install
  3. Run the Homebrew installation command
    • $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Note that the first command requires sudo for permission

This problem is caused by not updating OS X El Capitan. On MAC, git commands are under Xcode command tools. The installation process will be suspended and you need to wait patiently. Sometimes, because of network problems, you need to try several times. I tried three times before I succeeded.

Basic use of Homebrew

Brew search mysql // brew install mysql // Brew info mysql // uninstall package brew uninstall wget // Display the installed package brew list // View the help of brew -helpBrew update // Check for out-of-date (if there is a new version), this will list all installed packages, Brew upgrade brew upgrade mysql // Brew upgrade mysql // brew upgrade brew upgrade mysql // brew cleanup  brew cleanup mysqlCopy the code

Using the tree command

tree [OPTIONS] [directory]

Tree common commands are as follows:

  • -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 based on ls -f, to add a directory ‘/’, for the socket file to add a ‘=’, as an executable file to add a ‘*’, to add a FIFO ‘|’
  • -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 follows symbolic links to directories as if they were directories. Avoid links that lead to recursive loops
  • -n Does not color file and directory lists
  • -n Displays unprintable characters as is
  • -p Lists permission labels
  • -p Displays only file or directory names that match the template style
  • -q Prints unprintable characters in the file name as question marks
  • -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

References:

  1. The installation and use of Homebrew on Mac
  2. Tree command – Generates a directory structure with one key