Shellscript to monitor a log file if keyword triggers then execute a command?

Is there a cheap way to monitor a log file like tail -f log.txt, then if something like [error] appears, execute a command?

Thank you.


tail -fn0 logfile | \
while read line ; do
        echo "$line" | grep "pattern"
        if [ $? = 0 ]
                ... do something ...

Need Your Help

commons-logging-1.1.jar; cannot read zip file entry

java gwt maven

I have imported a GWT project from GIT , but when i run maven Install

Starting to learn to create iPhone apps

iphone osx

Well I'd like to create apps for the iPhone, starting out with really really basic stuff and working up, but I don't have a Mac at the moment (well I do but it's a powerPC ibook G4, which you can't

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.