1

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?

1
  • 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
    Commented Jan 27, 2015 at 8:53

1 Answer 1

0

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:
admin
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.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .