您的位置:首页 > 运维架构 > Shell

Shell脚本生成目录树结构文本文件 -- Snippets

2007-07-14 00:54 489 查看
不管出于什么目的, 本脚本的作用生成目录树状结构文本文件, 支持中文和有空格等的文件目录名. 比如
$./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.

gdt源代码及生成文件样本
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: