用tree命令顯示目錄結構(用tree命令顯示目錄結構)
2023-09-19 19:01:07 1
用tree命令顯示目錄結構? tree --help輸出結果:,下面我們就來說一說關於用tree命令顯示目錄結構?我們一起去了解並探討一下這個問題吧!
用tree命令顯示目錄結構
01、查看tree命令用法tree --help
輸出結果:
tree [-acdfghilnpqrstuvxACDFJQNSUX] [-H baseHREF] [-T title ] [-L level [-R]] [-P pattern] [-I pattern] [-o filename] [--version] [--help] [--inodes] [--device] [--noreport] [--nolinks] [--dirsfirst] [--charset charset] [--filelimit[=]#] [--si] [--timefmt[=]] [--sort[=]] [--matchdirs] [--ignore-case] [--fromfile] [--] [] ------- Listing options ------- -a All files are listed. -d List directories only. -l Follow symbolic links like directories. -f Print the full path prefix for each file. -x Stay on current filesystem only. -L level Descend only level directories deep. -R Rerun tree when max dir level reached. -P pattern List only those files that match the pattern given. -I pattern Do not list files that match the given pattern. --ignore-case Ignore case when pattern matching. --matchdirs Include directory names in -P pattern matching. --noreport Turn off file/directory count at end of tree listing. --charset X Use charset X for terminal/HTML and indentation line output. --filelimit # Do not descend dirs with more than # files in them. --timefmt Print and format time according to the format . -o filename Output to file instead of stdout. ------- File options ------- -q Print non-printable characters as '?'. -N Print non-printable characters as is. -Q Quote filenames with double quotes. -p Print the protections for each file. -u Displays file owner or UID number. -g Displays file group owner or GID number. -s Print the size in bytes of each file. -h Print the size in a more human readable way. --si Like -h, but use in SI units (powers of 1000). -D Print the date of last modification or (-c) status change. -F Appends '/', '=', '*', '@', '|' or '>' as per ls -F. --inodes Print inode number of each file. --device Print device ID number to which each file belongs. ------- Sorting options ------- -v Sort files alphanumerically by version. -t Sort files by last modification time. -c Sort files by last status change time. -U Leave files unsorted. -r Reverse the order of the sort. --dirsfirst List directories before files (-U disables). --sort X Select sort: name,version,size,mtime,ctime. ------- Graphics options ------- -i Don't print indentation lines. -A Print ANSI lines graphic indentation lines. -S Print with CP437 (console) graphics indentation lines. -n Turn colorization off always (-C overrides). -C Turn colorization on always. ------- XML/HTML/JSON options ------- -X Prints out an XML representation of the tree. -J Prints out an JSON representation of the tree. -H baseHREF Prints out HTML format with baseHREF as top directory. -T string Replace the default HTML title and H1 header with string. --nolinks Turn off hyperlinks in HTML output. ------- Input options ------- --fromfile Reads paths from files (.=stdin) ------- Miscellaneous options ------- --version Print version and exit. --help Print usage and this help message and exit. -- Options processing terminator.
常用選項說明:
Option | 說明 |
-a | 顯示所有文件和目錄,包含隱藏文件 |
-d | 只顯示目錄 |
-D | 顯示文件或目錄的更改時間 |
-f | 在每個文件或目錄之前,顯示完整的相對路徑名稱 |
-I | 不顯示符合範本樣式的文件或目錄名稱,多個範本間以|分隔 |
-N | 不轉義空格和特殊字符,可解決中文顯示亂碼的問題 |
-p | 顯示權限標示 |
-P | 只顯示符合範本樣式的文件或目錄名稱 |
-s | 顯示文件或目錄大小 |
-t | 用文件和目錄的更改時間排序 |
重要提示:tree後面的參數都區分大小寫。
02、用法示例:查看指定目錄的文件結構tree ./02-my
直接使用tree命令,不加任何參數,會列出指定目錄下的所有文件,包括子目錄中的文件。
03、用法示例:控制顯示項目的層級tree -L num ./02-my
命令中的num表示項目層級,可以為任意一個數值。
04、用法示例:只顯示文件夾tree -d ./02-my
05、忽略某個文件夾的內容tree -I "_book|node_modules" ./02-my
多個正則表達式之間以|分隔。
,