遍历目录中所有文件,并且统计文件类型。
#!/bin/bash#filename: filestat.sh#set -xif [ $# -ne 1 ];then echo $0 basepath; echofipath=$1declare -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