0

我正在寻找从tripwire报告中获取数值,如果该值大于0,请发送电子邮件。到目前为止的脚本如下所示:

#!/bin/bash

tripwire --check > /tmp/twreport

count=grep 'Total violations found: 0' /tmp/twreport 

if [ $count < 1 ]; then
  mail -s "[tripwire] Report for `uname -n`" user@example.com < /tmp/twreport
fi

不确定如何获取该值并将其设置为变量,或者是否有办法将其包含在 if 语句本身中。

4

1 回答 1

3

首先计算条目:

count=`grep -c '发现的总违规' /tmp/twreport`

下一步很简单,例如超过 3 次点击:

如果 [ $count > 3 ] ; 然后 mail -s "[tripwire] Report for `uname -n`" user@example.com
于 2017-05-02T18:04:50.257 回答