该shell是递归遍历/home目录,并输出每个文件的大小
#!/usr/bin/bash
#-*- coding:utf-8 -*-
count=0
function walk()
{
for file in `ls $1`
do
local path=$1"/"$file
if [ -d ${path} ];then
walk ${}path}
elif [ -f {path} ];then
size=$(ls -l ${path} | awk '{print $5}')
echo ${size} ${path}
else
countinue
fi
done
}
walk /home
网友评论