fs_file_list.sh
#!/system/bin/sh
######### #! /bin/bash
test_dir=$1
function read_dir(){
for file in `ls $1`
do
if [ -d $1"/"$file ]
then
read_dir $1"/"$file
else
echo $1"/"$file
fi
done
}
start=$(date +%s) #.%N)
#scan by ls -R
ls -l -R $test_dir
ls -l -R -r $test_dir
ls -l -R -S $test_dir
ls -l -R -t $test_dir
#ls -l -R -X $test_dir
tree ## tree source code : http://mama.indstate.edu/users/ice/tree/
#lsof
end=$(date +%s) #.%N)
file=$(ls -l -R $test_dir |grep "^-"|wc -l)
dir=$(ls -l -R $test_dir |grep "^d"|wc -l)
echo "file nums:$file"
echo "dir num:$dir"
#echo $start
#echo $end
time1=$(($end-$start))
#scan by ls
#start=$(date +%s) #.%N)
#read_dir $test_dir
#end=$(date +%s) #.%N)
#time2=$(($end-$start))
echo "ls time:$time1 s"
#echo "$time2 s"
如果需要统计文件数和目录数,可以参考如下命令:
ls -l * |grep "^-"|wc -l ---文件个数
ls -l * |grep "^d"|wc -l ---目录个数