发一个显示目录树的小程序(Python)
-
- 帖子: 23
- 注册时间: 2006-07-27 0:30
- 联系:
发一个显示目录树的小程序(Python)
我爱好Java,正在学习Python和Linux,很高兴和你交朋友!我的BLOG是http://shao-fan.com/blog
- FFFrog
- 帖子: 621
- 注册时间: 2006-05-12 23:28
- 来自: 江西乐平
- 联系:
-
- 帖子: 23
- 注册时间: 2006-07-27 0:30
- 联系:
Ubuntu是自动安装了Python的吧,那就直接把程序放到目录里,运行就可以啦 ./dtree.py,要想方便的话拷到/usr/bin里,随时都可以用了
我爱好Java,正在学习Python和Linux,很高兴和你交朋友!我的BLOG是http://shao-fan.com/blog
- FFFrog
- 帖子: 621
- 注册时间: 2006-05-12 23:28
- 来自: 江西乐平
- 联系:
-
- 帖子: 23
- 注册时间: 2006-07-27 0:30
- 联系:
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
- goldfox_79
- 帖子: 2004
- 注册时间: 2005-10-16 8:26
- 来自: 地球
-
- 帖子: 1331
- 注册时间: 2006-07-09 12:22
- 来自: 南京
linux下没有tree命令么?
~$sudo apt-get install tree -y --force-yes
~$cd howto
~/howto$tree
~/howto$tree --help
~$sudo apt-get install tree -y --force-yes
~$cd howto
~/howto$tree
代码: 全选
.
|-- C_C++
| |-- A_Quick_Intro_C++.pdf
| |-- An_Overview_of_the_C++.pdf
| |-- C_programming.pdf
| |-- C程序设计
| | |-- C++_guide.PDF
| | |-- algorithm.PDF
| | |-- appendix_A.pdf
| | |-- appendix_B.PDF
| | |-- array.PDF
| | |-- control_statement.PDF
| | |-- data_type.PDF
| | |-- function.PDF
| | |-- input_and_output.PDF
| | |-- pointer.PDF
| | |-- practical_tips.PDF
| | `-- structural_and_shared.PDF
| |-- EssentialC.pdf
| |-- O' Reilly - Practical C Programming 3rd Edition.pdf
| |-- The C++ Programming Language 3rd Ed.pdf
| |-- The C++ Standard Library.pdf
| `-- The_C_programming_Language
| |-- appa.html
| |-- appb.html
| |-- appc.html
| |-- chapter1.html
| |-- chapter2.html
| |-- chapter3.html
| |-- chapter4.html
| |-- chapter5.html
| |-- chapter6.html
| |-- chapter7.html
| |-- chapter8.html
| |-- images
| | |-- pic11.gif
| | |-- pic41.gif
| | |-- pic51.gif
| | |-- pic510.gif
| | |-- pic511.gif
| | |-- pic512.gif
| | |-- pic52.gif
| | |-- pic53.gif
| | |-- pic54.gif
| | |-- pic55.gif
| | |-- pic56.gif
| | |-- pic57.gif
| | |-- pic58.gif
| | |-- pic59.gif
| | |-- pic61.gif
| | |-- pic62.gif
| | |-- pic63.gif
| | |-- pic64.gif
| | |-- pic81.gif
| | `-- pic82.gif
| |-- index.html
| |-- intro.html
| |-- preface.html
| `-- preface1.html
|-- Linux
| |-- Aviation_HOWTO.pdf
| |-- Debian GNU Linux Bible.pdf
| |-- Intro_Linux.pdf
| |-- Linux_Dic.pdf
| |-- Linux_Kernel_2.4_Internals.pdf
| |-- Linux_Network_Admin_Guide.pdf
| |-- Linux_Tips_and_Tricks.pdf
| |-- Linux命令参考手册.pdf
| |-- Linux常见问题解答集中版.pdf
| |-- Moving_to_Ubuntu_Linux.chm
| |-- O'REILLY Learning the Unix OS.chm
| |-- Python_regexp.pdf
| |-- Teach_Yourself_Linux_in_24_Hours.pdf
| |-- UBUNTU服务器指南.pdf
| |-- Ubuntu_hacks.chm
| |-- Unix_regexp.pdf
| |-- debian-faq.en.pdf
| `-- sed&awk.pdf
|-- Python_perl_shell
| |-- ABS_Guide_cn.pdf
| |-- Advanced Perl Programming.pdf
| |-- Advanced_Bash_Scripting_Guide.pdf
| |-- Dive_Into_Python.chm
| |-- O'Reilly Learning Perl.pdf
| |-- TIPython
| | |-- code
| | | |-- SanityCheck.py
| | | |-- c01
| | | | |-- BorgSingleton.py
| | | | |-- NewSingleton.py
| | | | |-- Simple2.py
| | | | |-- SimpleClass.py
| | | | |-- SimpleClass.pyc
| | | | |-- SingletonDecorator.py
| | | | |-- SingletonMetaClass.py
| | | | |-- SingletonPattern.py
| | | | |-- differentReturns.py
| | | | |-- if.py
| | | | |-- list.py
| | | | |-- myFunction.py
| | | | |-- stringFormatting.py
| | | | |-- strings.py
| | | | |-- sum.py
| | | | `-- tmp
| | | |-- c03
| | | | |-- TemplateMethod.py
| | | | `-- tmp
| | | |-- c04
| | | | |-- ProxyDemo.py
| | | | |-- ProxyDemo2.py
| | | | |-- StateDemo.py
| | | | |-- mouse
| | | | | |-- MouseAction.py
| | | | | |-- MouseAction.pyc
| | | | | |-- MouseMoves.txt
| | | | | `-- tmp
| | | | |-- mousetrap1
| | | | | |-- MouseTrapTest.py
| | | | | `-- tmp
| | | | |-- mousetrap2
| | | | | |-- MouseTrap2Test.py
| | | | | `-- tmp
| | | | |-- statemachine
| | | | | |-- State.py
| | | | | |-- State.pyc
| | | | | |-- StateMachine.py
| | | | | |-- StateMachine.pyc
| | | | | `-- tmp
| | | | `-- tmp
| | | |-- c05
| | | | |-- Games.py
| | | | |-- Games2.py
| | | | |-- shapefact1
| | | | | |-- ShapeFactory1.py
| | | | | `-- tmp
| | | | |-- shapefact2
| | | | | |-- ShapeFactory2.py
| | | | | `-- tmp
| | | | `-- tmp
| | | |-- c06
| | | | |-- ChainOfResponsibility.py
| | | | |-- CommandPattern.py
| | | | |-- StrategyPattern.py
| | | | `-- tmp
| | | |-- c07
| | | | |-- Adapter.py
| | | | `-- tmp
| | | |-- c10
| | | | |-- BoxObserver.py
| | | | |-- BoxObserver.rsrc.py
| | | | |-- ObservedFlower.py
| | | | `-- tmp
| | | |-- c11
| | | | |-- FlowerVisitors.py
| | | | |-- PaperScissorsRock.py
| | | | |-- PaperScissorsRock2.py
| | | | `-- tmp
| | | |-- cX
| | | | `-- decorator
| | | | |-- alldecorators
| | | | | |-- CoffeeShop.py
| | | | | `-- tmp
| | | | |-- compromise
| | | | | |-- CoffeeShop.py
| | | | | `-- tmp
| | | | `-- nodecorators
| | | | |-- CoffeeShop.py
| | | | `-- tmp
| | | `-- util
| | | |-- Observer.py
| | | |-- Observer.pyc
| | | |-- Synchronization.py
| | | |-- Synchronization.pyc
| | | |-- TestSynchronization.py
| | | `-- tmp
| | `-- html
| | |-- Contents.htm
| | |-- DocIdx.htm
| | |-- FDocIdx.htm
| | |-- FramCont.htm
| | |-- FrontMtr.htm
| | |-- Index.htm
| | |-- IndexXTOC.htm
| | |-- Intro.htm
| | |-- Preface.htm
| | |-- Sect01.htm
| | |-- Sect02.htm
| | |-- Sect03.htm
| | |-- Sect04.htm
| | |-- Sect05.htm
| | |-- Sect06.htm
| | |-- Sect07.htm
| | |-- Sect08.htm
| | |-- Sect09.htm
| | |-- Sect10.htm
| | |-- Sect11.htm
| | |-- Sect12.htm
| | |-- Sect13.htm
| | |-- Sect14.htm
| | |-- Sect15.htm
| | |-- SimpCont.htm
| | |-- TIPyth00.gif
| | |-- TIPyth01.gif
| | |-- TIPyth02.gif
| | |-- TIPyth03.gif
| | |-- TIPyth04.gif
| | |-- TIPyth05.gif
| | |-- TIPyth06.gif
| | |-- TIPyth07.gif
| | |-- TIPyth08.gif
| | |-- TIPyth09.gif
| | |-- TIPython.err
| | |-- TIPython.rtf
| | `-- mindview.gif
| |-- perl.pdf
| `-- thinkCSpy.pdf
`-- man
|-- grep
|-- grep~
|-- regular_expr
|-- regular_expr~
`-- sed
30 directories, 191 files
代码: 全选
usage: tree [-adfgilnpqrstuxACDFNS] [-H baseHREF] [-T title ] [-L level [-R]]
[-P pattern] [-I pattern] [-o filename] [--version] [--help] [--inodes]
[--device] [--noreport] [--nolinks] [--dirsfirst] [--charset charset]
[<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.
-D Print the date of last modification.
-F Appends '/', '=', '*', or '|' as per ls -F.
-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.