mercredi 29 novembre 2017

How do I implement an IF statement into a while loop, and keep while loop running indefinitely? (Bash)

Take the following while loop I made which outputs the amount of times "string" appears in the file (file path and string ommited) every 60 seconds.

while true; do /path/to/file | grep -i "string" | wc -l; sleep 60; done

What's the best/easiest way to implement an IF statement so that, if the output gets above 100 I can send an email. I need the while loop to continue running indefinitely.

Aucun commentaire:

Enregistrer un commentaire