系统相关
首页 > 系统相关> > shell 生成文件统计信息

shell 生成文件统计信息

作者:互联网

#!/bin/bash
#file name : filestat.sh
if [ $# -ne 1 ];
then
    echo "Usage is $0 basepath";
    exit
fi
path=$1
declare -A statarray;
while read line;
do
    ftype=`file -b "$line" | cut -d, -f1`
    let statarry["$ftype"]++;
done <<< "`find $path -type f -print`"
echo ======File types and counts======
for ftype in "{!statarray[@]}";
do
    echo $type: ${statarray["$ftype"]}
done

 

标签:文件,shell,f1,basepath,filestat,生成,ftype,file,line
来源: https://www.cnblogs.com/zhg1016/p/10546029.html