#!/usr/bin/env bash echo "$0 $@" #print the command line for logging set -e logdir="./log"
if [ -d ${logdir} ] then echo "traverse the dir :"${logdir} else echo ${logdir}" is not a dir " exit fi
while true do for i in `ls ${logdir}`; do echo "#####the ${i} th process log :#####" echo ${i} cat ${logdir}/${i} | grep -iv "ERROR" # awk '/ERROR/' ${logdir}/${i} done sleep 30 done
循环里面 grep 会退出循环
awk 则不会