#! /bin/bash
if [ $# -eq 1 ];
then
echo $0 basepath
echo
fi
path=$1
declare -A array;
while read line;
do
ftype=`file -b $line`
let array["$ftype"]++;
done< <(find $path -type f -print)
echo ++++++++++File types and counts++++++++++
for ftype in "${!array[@]}";
do
echo $ftype : ${array["$ftype"]}
done
if [ $# -eq 1 ];
then
echo $0 basepath
echo
fi
path=$1
declare -A array;
while read line;
do
ftype=`file -b $line`
let array["$ftype"]++;
done< <(find $path -type f -print)
echo ++++++++++File types and counts++++++++++
for ftype in "${!array[@]}";
do
echo $ftype : ${array["$ftype"]}
done
结果: