#!/bin/bash
if [ `tail -15 <file> | grep error | wc -l` -gt 3 ]
then
echo "Too many errors..."
else
echo "Everything is fine."
fi
或者在命令行上:
if [ `tail -15 <file> | grep error | wc -l` -gt 3 ]; then echo "Too many errors..."; else echo "Everything is fine."; fi