#!/bin/bash
jiaoben=$@
#循环获取参数名称
counterror=0
countsh=0
countpl=0
echo "carry on please use ./counterror.sh *"
#读取每一份文件
for txt in $jiaoben
do
#分析是否是无文件
if [ -z $txt ]
then
echo "all file is none"
exit
fi
#获取文件格式
weiba=`echo $txt|awk -F "." '{print $NF}'`
if [ $weiba == 'sh' ]
then
let countsh++
fi
if [ $weiba == 'pl' ]
then
let countpl++
fi
if [ $weiba == 'log' ]
then
echo "the file is $txt"
if grep -i 'error' $txt &> /dev/null
then
let counterror++
fi
fi
done
echo ">>>>>>>>lfq analyse>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><"
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
echo "sh file are $countsh,pl file are $countpl"
echo "in log error file are $counterror"