转自:http://blog.chinaunix.net/uid-26000296-id-3575475.html
1 function ergodic(){ 2 for file in `ls $1` 3 do 4 if [ -d $1"/"$file ] 5 then 6 ergodic $1"/"$file 7 else 8 local path=$1"/"$file 9 local name=$file 10 local size=`du --max-depth=1 $path|awk '{print $1}'` 11 echo $name $size $path 12 fi 13 done 14 } 15 16 IFS=$' ' #这个必须要,否则会在文件名中有空格时出错 17 INIT_PATH="."; 18 ergodic $INIT_PATH