Skip to content

Instantly share code, notes, and snippets.

@handakumbura
Created July 2, 2016 10:08
Show Gist options
  • Save handakumbura/86ca262b00239210a992e0d1d4e6c300 to your computer and use it in GitHub Desktop.
Save handakumbura/86ca262b00239210a992e0d1d4e6c300 to your computer and use it in GitHub Desktop.
this script checks the existence of a char sequence in the last X number of lines of a files and plays a wave file if a match is made.
#!/bin/bash
#this script checks the existence of a char sequence in the last X number of lines of a files and plays a wave file if a match is made.
# sh logchecker.sh <number of lines to tail at one go> <logfile> <char sequence> <wav file to play>
while [ 1 -gt 0 ]; do
tail -n $1 $2 | grep -e "$3"
if [ $? -lt 1 ]; then
aplay $4 ;
exit ;
fi
sleep 10; #check interval
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment