雨中的高速公路 - bluetent的个人主页

我的电脑,最近新歌,欧美音乐,酷讯,电脑技术

用递归的方法在linux下遍历一个目录

11月 8th, 2004 · No Comments

代码如下:

#!/bin/sh

dosth()
{
#…
}

#遍历目录
dirlist()
{
dosth $1
for subitem in `ls $1`
do
if [ -d “$1/$subitem” ]
then
dirlist $1/$subitem
elif [ -f “$1/$subitem” ]
then
dosth $1/$subitem
fi
done
}

[ $# = 0 ] && { echo “Usage: $0 …”; exit; }

for i in `ls $1`
do
if [ -d “$1″ ]
then
dirlist $1
fi
done

关键字:遍历 递归 linux目录

历史上的今天

Tags: 原创文档

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment