需要帮助从目录中获取多个日志文件并grep错误

时间:2015-07-10 18:01:33

标签: linux shell

这就是我到目前为止我的问题是如何在脚本中添加所有日志文件的目录

#!/bin/bash
while true ; do
    tail ~/Path
    grep -o 'ERROR No appender named [MicromuseAppender] could be found' ' /dyn/logfiles/ (path)' &> /dyn/logfiles/.log
    if [ $? -eq 0 ] ; then
        echo Error found
        break
    fi
    sleep 10
done

1 个答案:

答案 0 :(得分:0)

转到目标文件夹并从所有文件中获取

grep 'ERROR No appender named [MicromuseAppender] could be found' $PATH/*

输出就像

<Filename>:<line which contains the grep'ed string>

仅获取文件名,其中错误字符串至少发生一次。

grep 'ERROR No appender named [MicromuseAppender] could be found' $PATH/* | cut -f1 -d: | sort | uniq