tree命令的使用
有些工作在linux下完成就是比在windows下完成高效!?
windows和linux都有tree命令,主要功能是創建文件列表,將所有文件以樹的形式列出來
windows下的tree比較垃圾,只有兩個參數,/F 是遞歸顯示每個文件夾的名稱;/A 是使用ASCII字符而不是擴展字符,感覺還不如不加/A 參數好。
linux下的tree就比較強大了,但一般系統并不自帶這個命令,需要手動下載安裝:sudo apt-get install tree 。文件很小,只有31K,但功能可強大了!
?tree命令的參數解釋,摘自http://www.linuxso.com/command/tree.html
-a 顯示所有文件和目錄。 -A 使用ASNI繪圖字符顯示樹狀圖而非以ASCII字符組合。 -C 在文件和目錄清單加上色彩,便于區分各種類型。 -d 顯示目錄名稱而非內容。 -D 列出文件或目錄的更改時間。 -f 在每個文件或目錄之前,顯示完整的相對路徑名稱。 -F 在執行文件,目錄,Socket,符號連接,管道名稱名稱,各自加上"*","/","=","@","|"號。 -g 列出文件或目錄的所屬群組名稱,沒有對應的名稱時,則顯示群組識別碼。 -i 不以階梯狀列出文件或目錄名稱。 -I 不顯示符合范本樣式的文件或目錄名稱。 -l 如遇到性質為符號連接的目錄,直接列出該連接所指向的原始目錄。 -n 不在文件和目錄清單加上色彩。 -N 直接列出文件和目錄名稱,包括控制字符。 -p 列出權限標示。 -P 只顯示符合范本樣式的文件或目錄名稱。 -q 用"?"號取代控制字符,列出文件和目錄名稱。 -s 列出文件或目錄大小。 -t 用文件和目錄的更改時間排序。 -u 列出文件或目錄的擁有者名稱,沒有對應的名稱時,則顯示用戶識別碼。 -x 將范圍局限在現行的文件系統中,若指定目錄下的某些子目錄,其存放于另一個文件系統上,則將該子目錄予以排除在尋找范圍外。上面列的不怎么全,完整的幫助信息是這樣的:
usage: tree [-adfghilnpqrstuvxACDFNS] [-H baseHREF] [-T title ] [-L level [-R]][-P pattern] [-I pattern] [-o filename] [--version] [--help] [--inodes][--device] [--noreport] [--nolinks] [--dirsfirst] [--charset charset][--filelimit #] [<directory list>]-a All files are listed.-d List directories only.-l Follow symbolic links like directories.-f Print the full path prefix for each file.-i Don't print indentation lines.-q Print non-printable characters as '?'.-N Print non-printable characters as is.-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.-D Print the date of last modification.-F Appends '/', '=', '*', or '|' as per ls -F.-v Sort files alphanumerically by version.-r Sort files in reverse alphanumeric order.-t Sort files by last modification time.-x Stay on current filesystem only.-L level Descend only level directories deep.-A Print ANSI lines graphic indentation lines.-S Print with ASCII graphics indentation lines.-n Turn colorization off always (-C overrides).-C Turn colorization on always.-P pattern List only those files that match the pattern given.-I pattern Do not list files that match the given pattern.-H baseHREF Prints out HTML format with baseHREF as top directory.-T string Replace the default HTML title and H1 header with string.-R Rerun tree when max dir level reached.-o file Output to file instead of stdout.--inodes Print inode number of each file.--device Print device ID number to which each file belongs.--noreport Turn off file/directory count at end of tree listing.--nolinks Turn off hyperlinks in HTML output.--dirsfirst List directories before files.--charset X Use charset X for HTML and indentation line output.--filelimit # Do not descend dirs with more than # files in them.參數很多,用法也很靈活,根據自己的需要選擇吧。
?
使用tree命令生成樹形結構
分別使用以下命令:tree、tree /f 命令,就可以看到屏幕的效果了,還可以使用tree /a等命令,來生成想要的文件目錄。
導出生成的文件目錄
使用tree /f > tree.txt命令,就可以把生成的文件目錄樹形結構寫入到tree.txt文件中了,tree.txt這個文件名稱是可以修改的。打開對應的文件目錄,就可以看到多了一個tree.txt的文件,其中tree文件里面的內容,和屏幕輸出的內容是一致的,以后就可以使用tree命令來生成文件目錄的樹形結構了。
為了方便大家,我把這個命令在網盤里面備份了一個:http://ma6174.ys168.com/?,在linux軟件目錄下面,大家可以下載到U盤上,萬一電腦沒聯網也能用!用法很簡單,轉到tree這個文件所在目錄,用 ?./tree ?這個命令運行,參數一樣的。?
總結
- 上一篇: std::make_any
- 下一篇: OpenGL中的Uniform bloc