用find,cat和if编写一个shell脚本

时间:2013-01-15 15:53:58

标签: shell if-statement grep cat

我正在做一个搜索带有年龄的日志文件的scipt,并比较谁在日志中有一串文本,如果继续创建一个函数是正确的,但不受影响。我感谢任何建议或帮助

#!/bin/bash
file= find /AUX/backup/log/ -iname "*.log" -daystart -type f -mtime 1
if cat $file | grep -qw “INF - Status = completed."  
then
  echo "there is OK" 
else
  echo "there is KO" 
fi

1 个答案:

答案 0 :(得分:0)

#!/bin/bash
file=`find /AUX/backup/log/ -iname "*.log" -daystart -type f -mtime 1`
if grep -qw “INF - Status = completed."  < $file
then
  echo "there is OK" 
else
  echo "there is KO" 
fi