If, for instance, you have a file with the contents:
FOO
BAR
FOO
$ tail -f file | grep -m2 FOO
prints FOO twice but never returns. Whereas
$ tail -f file | grep -m2 -e FOO -e BAR
will exit.

This is because (from the grep(1) manual):

	grep ensures that the standard input is positioned to just
	just after  the  last matching line before exiting, regardless of
	the presence of trailing context lines.

This bit me as I was trying to scan xscreensaver-command -watch for an unblanking event. However, because no events followed the UNBLANK immediately, grep didn't return and my script would not continue. I therefore rely on the LOCK event that (hopefully) preceeds the UNBLANK. It's not a big deal if this fails; I'll have to unlock my ssh-agent manually...

2007/05/25 12:46

The explosion of interest in GUIs since 1984 has had the unfortunate effect of obscuring the virtues of CLIs. The design of consumer software, in particular, has become heavily skewed towards GUIs. While this is a good choice for the novice and casual users that constitute most of the consumer market, it also exacts hidden costs on more expert users as they run up against the expressiveness limits of GUIs--costs which steadily increase as the users take on more demanding problems. Most of these costs derive from the fact that GUIs are simply not scriptable at all--every interaction with them has to be human-driven.

The Art of UNIX Programming, Eric S. Raymond
2007/03/27 09:50
THE MEATENING!! -- I strongly suggest that you do not send mail to that link.