shell 递归遍历目录

2018-03-07  本文已影响0人  朝西的生活
count=0

function walk()
{
    for file in `ls $1`
    do
        local path=$1"/"$file
        if [ -d $path ]
        then
            echo "DIR $path"
            walk $path
        else
            echo "FILE $path"
            num=$(wc -l $path | awk '{ print $1 }')
            echo $num
            count=`expr $count + $num`
        fi
     done
}
walk miwifi
echo $count
上一篇下一篇

猜你喜欢

热点阅读