[这个贴子最后由南非蜘蛛在 2002/06/06 01:04pm 编辑]
这是程序,在linux下可以,到solaris下就不行了,大家看看有什么错误
#!/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"
# ./tree
/home/ghost
./tree: ----1,: 没找到
sed: 命令错乱:s,[^/]*/([^/]*)$,
因该出来一些结果
.
`----shellp
`----updates
`----wu-ftpd-2.4
| `----doc
| | `----examples
| `----src
| | `----config
| | `----makefiles
| `----support
| | `----makefiles
| | `----man
| `----util
| ultra-guest 回复于:2002-06-06 15:29:22 |
| [这个贴子最后由ultra-guest在 2002/06/06 03:49pm 编辑] 不错。 #!/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" 不过没`----了。。 |
| mathon 回复于:2002-06-06 17:25:55 |
| 那是因为`是特殊字符,要用\转义的。我将此程序重新改写了一下, 我用|代替了`。 其中中间的几字空格是TAB键而不是多个空格。 当然还有可改进的地方。如最后一行的首个|不应该再有。 dir=${1:-.} cd $dir;pwd=`pwd`;echo $pwd find $pwd -type d|sort -f|sed -e "s,^$pwd,," -e "/^$/d" -e "s,[^/]*/\([^/]*\)$,|----\1," -e "s,[^/]*/,+ ,g" -e "s, +, ,g" -e"s,+,|,g" |
| 南非蜘蛛 回复于:2002-06-06 18:01:39 |
| [这个贴子最后由南非蜘蛛在 2002/06/06 06:02pm 编辑] 酷哥,你真有一套,佩服佩服 好像就是有一点没有对齐,能不能在调一下 |