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?
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?
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.