不管出于什么目的, 本脚本的作用生成目录树状结构文本文件, 支持中文和有空格等的文件目录名. 比如
$./gdt.sh /cygdrive/e/ccccc -o
将/cygdrive/e/ccccc目录树状结构文本文件ccccc.txt. 如果不带目录名参数, 则生成当前目录树状结构.
本脚本完成使用Bash编程, 并且未使用sed, awk等.
具体用法和选项含意可使用-h显示简单帮助, 或见文章结尾源代码:
$./gdt.sh -h
用法说明如下:
usage: gdt.sh [-h] [-o [file name]] [-n] [directory]
Generate directory tree.
|-- for file, /-- for empty directory, +-- for non-empty directory.
Options:
-h help page, any other options ignored
-o output results to a file, no file name follwed means output file has a name same as directory.
-n no screen output, if no file specificed, it redirects to /dev/null
All extra arguments will be ignored automatically.
Only the first directory will be considered if more exist.