文件类型统计
1 #!/bin/bash 2 3 if [ $# -ne 1 ] 4 then 5 echo 'please input one ' 6 fi 7 path=$1 8 declare -A wow 9 10 while read line; 11 do 12 ftype=`file -b $line` 13 let wow["$ftype"]++; 14 done< <(find $path -type f -print ) 15 16 echo ============= file type ================ 17 18 for ftype in "${!wow[@]}"; 19 do 20 echo $ftype : ${wow["$ftype"]} 21 done
脚本可以遍历指定目录下所以文件,然后统计文件信息。