无法grep结果计数

时间:2017-10-12 13:19:48

标签: unix grep find

我正在尝试找到特定类型的文件并grep字符串“COMPLETED KO”,如果计数大于0,那么它将通过邮件发送包含字符串的行。

以下是剧本:

  #!/bin/ksh

cd /home/scripts/log

FILES=`find . -type f -name "TOKEN*" -mtime 1`
ML="ABC@xyz.com"
cd $DIR

err_KO=`grep "ERROR" $FILES |wc -l` 
err_ko=`grep "ERROR" $FILES` > /dev/null 2>&1
if [ $err_KO -gt 0 ]
then
echo "error in the files due to KO $err_ko" |mailx -s "KO errors" -r "abcd@xyz.com" $ML
exit 0
fi

但是在运行脚本时,我没有得到所需的结果。

日志:

grep: ./LOG_EQUENS/TOKEN_EQUENS_STOPDEUT_0005000000087916_20171010160102.log: No such file or directory
grep: ./LOG_EQUENS/TOKEN_EQUENS_LOGVODAF_00050000000879D0_20171011061846.log: No such file or directory
grep: ./LOG_SETEFI/TOKEN_SETEFI_SETOVFPM_0005000000087938_20171011011816.log: No such file or directory
grep: ./LOG_SETEFI/TOKEN_SETEFI_SETALMON_00050000000879A6_20171011035809.log: No such file or directory
grep: ./LOG_SETEFI/TOKEN_SETEFI_SETATROA_00050000000879B4_20171011043340.log: No such file or directory
grep: ./LOG_SETEFI/TOKEN_SETEFI_SETSOROA_00050000000879B6_20171011043345.log: No such file or directory

欢迎任何帮助

0 个答案:

没有答案