[Bash shell] 纯文本查看 复制代码
#!/bin/bash
if [ $# -ne 1 ];
then
echo $0 you_ path;
echo
fi
path=$1
declare -A statarray;
while read line;
do
ftype=`file -b "$line" | cut -d, -f1`
#echo $ftype | grep "[0-9][0-9]-bit" &> /dev/null
#if [ $? -eq 0 ];
#then
# ftype=`echo $ftype | awk -F, '{print $1}'`
#fi
let statarray["$ftype"]++;
done< <(find $path -type f -print)
#echo ======================File types and counts======================
for ftype in "${!statarray[@]}";
do
echo $ftype : ${statarray["$ftype"]}
done