linux下获取目录及子目录下所有文件名和路径

转自http://www.ahlinux.com/shell/7809.html

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 name size $path
fi
done
}

IFS=$’\n’

INIT_PATH=”.”;
ergodic $INIT_PATH

你可能感兴趣的:(scripts)