Personal tools
You are here: Home 资源中心 原始部落 13109 使用 tree , enscript 命令
Document Actions

使用 tree , enscript 命令

by yangh posted on Mar 15, 2005 02:55 AM last modified Mar 15, 2005 02:55 AM
介绍一些使用 tree 和 enscript 命令的经验。

tree

tree 命令是用来打印目录结构的,可以树状的方式输出,以便你能方便的知道目录中的内容。

主要参数:

  • -C 高亮输出
  • -s 输出文件大小
  • -H baseURL 输出 html. 其中 baseURL 表示生成的 html 将使用的连接的前缀。以便你放在 web 服务器上时可以正确连接到目录位置。
  • -o 指定输出文件

简单的使用 tree 效果如下:

    $> tree init_repos_layout/
    init_repos_layout/
    |-- branches
    |-- tags
    |-- trunk
    `-- vendor

    4 directories, 0 files

高级的用法1:高亮输出:

    $> tree -C init_repos_layout/

高级的用法2:Html + 高亮 输出:

    $> tree -C -s -H http://www.gnome-cn.org init_repos_layout/ -o /tmp/list.html

"效果1":list.html

enscript

enscript 是一个用来格式化文本文件的工具,它可以输出多种格式,如: PostScript, HTML, RTF, ANSI。还支持语法高亮。

主要参数:

  • --language 用于指定输出的格式,可用值有:PostScript,html,overstrike,rtf,ansi
  • -E 用于指定源文件格式,如: c,sh,html,bash,perl 等,可以使用 enscript --help-highlight 来得到已经支持的列表。
  • --color 用于指定使用高亮语法。在 Debian GNU/Linux 中的 enscript 可用值为布尔型的 1 和 0. 其它系统可能为字符串 emacs。

用法1: 格式化 C 语言代码为高亮的 html 文件:

    enscript --language=html -Ec --color=1 mlock.c -o mlock.c.html

"效果2":mlock.c.html