shell-递归扫描当前目录及子目录下的文件
#!/bin/sh# 递归扫描当前目录及子目录下的文件
function ergodic(){
for file in `ls $1`
do
if [ -d $1"/"$file ]
then
ergodic $1"/"$file
else
local path=$1"/"$file
local name=$file
local size=`du --max-depth=1 $path|awk '{print $1}'`
echo $path #$name $size
fi
done
}
IFS=
\n' #这个必须要,否则会在文件名中有空格时出错
INIT_PATH=".";
ergodic $INIT_PATH
页:
[1]