如何用 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" ]
搜索更多相关主题的帖子:
Shell 递归 脚本 程序 编写