天天加油 - 助您成才
如何用Shell脚本编写递归程序
您正在看的Linux|Unix是:如何用Shell脚本编写递归程序。

UNIX Shell 脚本类似 DOS 的批处理命令,但比较起来 UNIX Shell 的功能更强大,在某些方面,Shell 甚至超过了一些高级语言。

下边的 Shell 脚本演示了如何用 Shell 脚本编写递归程序。

运行前先执行下述准备命令:

ln tree.sh /usr/bin/tree

ln tree.sh /usr/bin/wtree

ln tree.sh /usr/bin/dtree

rm tree.sh

# tree.sh

# Depth first Directory list

dtree() {

PWD=`pwd|sed 's/\/\$//`

for d in $*

do

echo "${PWD}/$d"

[ -d "$d" -a -x "$d" ] && {

cd "$d"

dtree *

cd ..

PWD=`pwd|sed 's/\/\$//` # restore PWD

}

done

}

# Depth first Directory list

wtree() {

PWD=`pwd|sed 's/\/\$//`

for d in $*

do

echo ${PWD}/$d

done

for d in $*

do

[ -d "$d" -a -x "$d" ] && {

cd $d

wtree *

cd ..

}

done

}

# Directory list

tree() {

PWD=`pwd|sed 's/\/\$//`

for d in $*

do

echo ${PWD}/$d

done

}

# main

TREE=`basename $0`

if [ "$1" ]

then DIR="$1"

else DIR="."

fi

if cd $DIR

then $TREE *

else echo "$0: Directory $1 read fail."

fi

# (End)

排行

  1. 我也来学做嵌入式Linux系统V0.1(
  2. 全力打造Linux服务器配置大全
  3. 利用BusyBox定制Linux Live CD
  4. 在CentOS 4.4上安装配置OpenVZ
  5. 红帽RHCE证书RH302考试
  6. 程序设计师的迷思---工具与数据库
  7. 数据库管理员的难题,选择MySQL还
  8. 技巧:用Sort和Tsort对文件排序
  9. Vpopmail+Procmail过滤垃圾邮件
  10. PHP配置入门的福音PHP.ini中文版
  11. sed与unix命令等价代码鉴赏
  12. 如何编译配置Apache中的Configur
  13. qmail+webmailonLinux9安装全过程
  14. Solaris下的常用命令和使用方法
  15. Unix应用技巧:solarisraid制作大
  16. 利用vnc远程图形界面控制Linux
  1. RHAS3上快速实现磁盘配额解决方案
  2. 抢先试用----防火墙KWF6.0新功能
  3. stty使用方法
  4. tr的使用方法
  5. find和xargs使用详解
  6. 全力打造Linux服务器配置大全
  7. 利用BusyBox定制Linux Live CD
  8. 在系统工作时调整分区:移动/hom
  9. 在CentOS 4.4上安装配置OpenVZ
  10. 惠普企业资产维护管理解决方案
  11. 红帽RHCE证书RH302考试
  12. 你想用linux来谋生吗?
  13. 深入学习Linux的用户和组---基础
  14. 系统管理员之DHCP+DNS(bind)==DD
  15. RHCE考试时间及费用
  16. 详细介绍James中的主机名和本地域
  1. 我也来学做嵌入式Linux系统V0.1(
  2. 全力打造Linux服务器配置大全
  3. 配置 FTP 服务器以支持 IPv6
  4. Architect V6.0 for Linux 试用版
  5. Eclipse for Linux on POWER 的安
  6. OProfile for Linux on POWER 识
  7. RPM卸载软件完全手册
  8. Mysql 5.0.22 Cluster for RedHa
  9. Qmail邮件系统的安全分析和改进研
  10. 点评主流中间件技术平台
  11. Linux“装机”一条龙
  12. 一种不为人知但功能强大的流行工
  13. Linux系统、设备、软件简易安装指
  14. 漫谈:怎么在Linux上使用SSH2
  15. LINUX中使用gnuplot让您的数据可
  16. Linux上安装GCC编译器过程实录

最近更新

  • 推荐阅读
  • Linux|Unix《如何用Shell脚本编写递归程序》如何用Shell脚本编写递归程序
    关于我们 | 版权申明 | 广告服务 | 友情链接 | 网站地图 | 使用帮助 | ©2006-2008 TTADD.COM