how to beep on tail -f event
Solution 1:
Just define beep
as following:
beep() { read a || exit; printf "$a\007\n"; beep; }
Then, you can use your command:
tail -f development.log | grep "something rare" | beep
Solution 2:
GNU screen has a built-in feature to beep when a given window changes: see the relevant section of the man page.
Headline summary:
$ screen
$ tail -f yourfile.log # inside the screen session
<C-a> M # "Window 0 (bash) is now being monitored for all activity."
As pointed out in comments, this will beep on every new log entry, not just those that match "something rare", so this doesn't do quite what the OP asked for. Still a useful trick to know IMHO.
You can get the best of both worlds by opening two screen
windows (<C-a> c
to open a window, <C-a> <C-a>
to toggle between two windows):
- monitored, with
tail -f yourfile.log | grep 'something rare'
- unmonitored, with a plain
tail -f yourfile.log
Then you can sit watching the log scroll past in window 2, and you'll get beeped from window 1 when "something rare" occurs.
screen
is awesomely versatile - I highly recommend reading up on it.