shell 递归遍历目录

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

你可能感兴趣的:(shell 递归遍历目录)