还可以用脚本解决,如果需要经常执行此操作,脚本方便一些,稍加更改还能输出到日志文件
#!bin/sh
for file in /test/*.log ;
do
if test -f $file
then
e=`grep 关键字 "$file"|wc -l`
echo "关键字--"$file"--"$e
else
echo $file 是目录
fi
done
自己建个脚本,每次需要只要执行一下脚本就行了