您的位置:首页 > 文档 > Shell >
 文章分类 

列出目录树


创建:2005-10-26 00:49:41
作者:Unlinux
来自: http://www.Unlinux.com

  下面的短小的shell程序可以列出目录树, 充分利用了sed强大的模式匹配能力.
  目录树形式如下:
  .
  `----shellp
  `----updates
  `----wu-ftpd-2.4
  | `----doc
  | | `----examples
  | `----src
  | | `----config
  | | `----makefiles
  | `----support
  | | `----makefiles
  | | `----man
  | `----util
  脚本如下:
  #!/bin/sh
  # dtree: Usage: dtree [any directory]
  dir=${1:-.}
  (cd $dir; pwd)
  find $dir -type d -print | sort -f | sed -e "s,^$1,," -e "/^$/d" -e "s,[^/]*/([^/]*)$,`----1," -e "s,[^/]*/,| ,g"

转载自:http://www.unlinux.com/doc/shell/20051026/27.html

评论】 【加入收藏夹】 【 】 【打印】 【关闭
 *  请尊重我们的劳动,转载请注明出自UnLinux.Com及作者名 * 

※ 相关链接
无相关信息
Copyright © 2005 UnLinux.Com All Rights Reserved