How do I use a command like:

tail -f /home/user/log.txt | grep '!calladmin\|admin' 

To send an IRC message to me when !calladmin or admin are posted in the log?

Or is there an easier way to do this?

  • I took you remark concerning the IRC message to be just background information. Do you need some hint of how to use an IRC-Client on command line or is your question answered? – nlu Jan 27 '15 at 8:53

For the matches you are trying to get here, simply using "admin" would be enough, as "calladmin" contains it.

However you probably don't want that. Regexes have the notion of word boundaries, so you can look for a single word "admin" like this:

echo "The single word admin"| grep -o "\badmin\b"
# Output:
echo "Badminton is the most popular sport in this administrative area" | grep -o "\badmin\b"
(mo match)

So you could match for either "admin" or "calladmin" like this:

some_input_pipe | grep -o "\badmin\b\|\bcalladmin\b"

However you cannot easily include the exclamation mark, as this is not considered part of a word.

  • You haven't answered the question of how to make this trigger sending an IRC message. – Barmar Jan 26 '15 at 22:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.