tree命令的使用
有些工作在linux下完成就是比在windows下完成高效!?
windows和linux都有tree命令,主要功能是創(chuàng)建文件列表,將所有文件以樹的形式列出來(lái)
windows下的tree比較垃圾,只有兩個(gè)參數(shù),/F 是遞歸顯示每個(gè)文件夾的名稱;/A 是使用ASCII字符而不是擴(kuò)展字符,感覺還不如不加/A 參數(shù)好。
linux下的tree就比較強(qiáng)大了,但一般系統(tǒng)并不自帶這個(gè)命令,需要手動(dòng)下載安裝:sudo apt-get install tree 。文件很小,只有31K,但功能可強(qiáng)大了!
?tree命令的參數(shù)解釋,摘自http://www.linuxso.com/command/tree.html
-a 顯示所有文件和目錄。 -A 使用ASNI繪圖字符顯示樹狀圖而非以ASCII字符組合。 -C 在文件和目錄清單加上色彩,便于區(qū)分各種類型。 -d 顯示目錄名稱而非內(nèi)容。 -D 列出文件或目錄的更改時(shí)間。 -f 在每個(gè)文件或目錄之前,顯示完整的相對(duì)路徑名稱。 -F 在執(zhí)行文件,目錄,Socket,符號(hào)連接,管道名稱名稱,各自加上"*","/","=","@","|"號(hào)。 -g 列出文件或目錄的所屬群組名稱,沒有對(duì)應(yīng)的名稱時(shí),則顯示群組識(shí)別碼。 -i 不以階梯狀列出文件或目錄名稱。 -I 不顯示符合范本樣式的文件或目錄名稱。 -l 如遇到性質(zhì)為符號(hào)連接的目錄,直接列出該連接所指向的原始目錄。 -n 不在文件和目錄清單加上色彩。 -N 直接列出文件和目錄名稱,包括控制字符。 -p 列出權(quán)限標(biāo)示。 -P 只顯示符合范本樣式的文件或目錄名稱。 -q 用"?"號(hào)取代控制字符,列出文件和目錄名稱。 -s 列出文件或目錄大小。 -t 用文件和目錄的更改時(shí)間排序。 -u 列出文件或目錄的擁有者名稱,沒有對(duì)應(yīng)的名稱時(shí),則顯示用戶識(shí)別碼。 -x 將范圍局限在現(xiàn)行的文件系統(tǒng)中,若指定目錄下的某些子目錄,其存放于另一個(gè)文件系統(tǒng)上,則將該子目錄予以排除在尋找范圍外。上面列的不怎么全,完整的幫助信息是這樣的:
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.參數(shù)很多,用法也很靈活,根據(jù)自己的需要選擇吧。
?
使用tree命令生成樹形結(jié)構(gòu)
分別使用以下命令:tree、tree /f 命令,就可以看到屏幕的效果了,還可以使用tree /a等命令,來(lái)生成想要的文件目錄。
導(dǎo)出生成的文件目錄
使用tree /f > tree.txt命令,就可以把生成的文件目錄樹形結(jié)構(gòu)寫入到tree.txt文件中了,tree.txt這個(gè)文件名稱是可以修改的。打開對(duì)應(yīng)的文件目錄,就可以看到多了一個(gè)tree.txt的文件,其中tree文件里面的內(nèi)容,和屏幕輸出的內(nèi)容是一致的,以后就可以使用tree命令來(lái)生成文件目錄的樹形結(jié)構(gòu)了。
為了方便大家,我把這個(gè)命令在網(wǎng)盤里面?zhèn)浞萘艘粋€(gè):http://ma6174.ys168.com/?,在linux軟件目錄下面,大家可以下載到U盤上,萬(wàn)一電腦沒聯(lián)網(wǎng)也能用!用法很簡(jiǎn)單,轉(zhuǎn)到tree這個(gè)文件所在目錄,用 ?./tree ?這個(gè)命令運(yùn)行,參數(shù)一樣的。?
總結(jié)
- 上一篇: std::make_any
- 下一篇: 新加坡a50指数