I'm looking to pull multiple pieces from a file, or at least watch for pieces in a log file if they should occur, but I don't want to setup multiple
tail | grep sessions. Instead I'd like to just tail the output of each grep.
I suppose I could do this with
awk, but perhaps there is something closer to this idea already.
For example the command might look something like this:
tail -f /var/log/syslog | teegrep cron1 -f CRON | teegrep cloud-init2 -f CLOUD-INIT
The output would be the files CRON and CLOUD-INIT, while all things would go to stdout by the end. Only the matches for 'cron1' and 'cloud-init2' lines would wind up in their respective files.
Maybe it's already part of a command and I have just not known about it. Or possibly just some bash/zsh trickery that would do the same thing.
Either way: Is there a command that combines
grep such that in a pipeline the tee part can direct matches to a file?