标签:遍历目录并且统计
遍历目录中所有文件,并且统计文件类型。
#!/bin/bash
#filename: filestat.sh
#set -x
if [ $# -ne 1 ];
then
echo $0 basepath;
echo
fi
path=$1
declare -A statarray;
while read line;
do
ftype=`file -b "$line"`
let statarray["$ftype"]++;
done< <( find $path -type f -print )
echo ===============================File types and counts==================================
for ftype in "${!statarray[@]}";
do
echo $ftype : ${statarray["$ftype"]}
done标签:遍历目录并且统计
原文地址:http://bronte.blog.51cto.com/2418552/1431640