文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>bash 遍历目录

bash 遍历目录

时间:2009-08-07  来源:AppleDragon

#!/bin/bash
function usage {
echo "Usage: ./$0 DIR"
}
recursive () {
   first_directory=$1
   cd $first_directory
   directory_array=(*);
  
    for directory in ${directory_array[@]}; do
        if [ -d $directory ] ; then
             (( directory_count += 1 ))
             recursive $directory
             echo In Directory : `pwd`
             domywork
             cd ..
        fi
    done
}

function domywork {
for file in `ls *.java`;
do
        # do sth
        grep 'ltable' $file > /dev/null;
        (( a = $? ))
        grep 'ismanagingfocus' $file > /dev/null;
        (( b = $? ))
        grep 'ismanagingfocus = true' $file > /dev/null;
        (( c = $? ))
        if [ $a -eq 0 ]; then

                if [ $b  -gt 0 ]; then
                        echo $directory$file;
                 fi
                 if [ $c  -eq 0 ]; then
                        echo $directory$file;
                 fi

        fi
 
done
}

#check for required parameters
if  [ ${#1} -gt 0  ]; then
cd $1
     echo "In Directory : `pwd`"
     domywork
     recursive "$1"
     echo "$directory_count directories processed."
else
     #print usage information
     usage
fi
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载