用户名: 密码: 免费注册 忘记密码? 网站地图 | 加入收藏 | 设为首页
首页 | 新闻 | 工具 | 系统 | 办公 | 聊天 | 多媒体 | 网页 | 运营 | 平面 | 欣赏 | 数据库 | 程序 | 服务器 | 组网
网页 | 3dmax | Ghost | Windows Xp| Dreamweaver | photoshop | Flash | office | Alexa | Css | QQ | Asp | PHP | Jsp | Access
Flash MX 2004入门 | 网站推广策略 | CorelDRAW入门 | ASP学习 | 网站建设大师功 | Word入门
  iTbulo.com > 学院 > 程序开发教程 > shell教程 > 文章正文
Shell递归程序设计-目录列表
iTbulo.COM 2006-4-26 佚名()
UNIXShell脚本类似DOS的批处理命令,但比较起来UNIXShell的功能更强大,在某些方面,Shell甚至超过了一些高级语言。
下边的Shell脚本演示了如何用Shell脚本编写递归程序。

运行前先执行下述准备命令:
lntree.sh/usr/bin/tree
lntree.sh/usr/bin/wtree
lntree.sh/usr/bin/dtree
rmtree.sh


#tree.sh

#DepthfirstDirectorylist
dtree(){
PWD=`pwd|sed's/\/\$//`
fordin$*
do
echo"${PWD}/$d"
[-d"$d"-a-x"$d"]&&{
cd"$d"
dtree*
cd..
PWD=`pwd|sed's/\/\$//`#restorePWD
}
done
}

#DepthfirstDirectorylist
wtree(){
PWD=`pwd|sed's/\/\$//`
fordin$*
do
echo${PWD}/$d
done
fordin$*
do
[-d"$d"-a-x"$d"]&&{
cd$d
wtree*
cd..
}
done
}

#Directorylist
tree(){
PWD=`pwd|sed's/\/\$//`
fordin$*
do
echo${PWD}/$d
done
}

#main
TREE=`basename$0`
if["$1"]
thenDIR="$1"
elseDIR="."
fi
ifcd$DIR
then$TREE*
elseecho"$0:Directory$1readfail."
fi

#(End)
文章搜索
相关资讯
相关文章 相关下载
FREEBSD下使用crunch集成编译程序
从ifconfig中得到IP地址
赶走一些你不希望进入的用户
Shell编程
Bash中的特殊字符
焦点信息