I'm looking for a command or a bash script that can perform the following:
(see nice picture here: http://i.stack.imgur.com/4VYOf.png but I cannot post it because I have not enough reputation)
That is: I want a "supermerge" to merge the standard in stream with contents written continuously to a log file (var/log/messages in this example). The result should be written to standard out.
The reason is to scans for certain error messages and these messages can both be written to a log file and to standard out.
For example:
my_strange_program /var/log/messages | supermerge /var/log/messages | my_log_scanner
- my_strange_program can send errors to standard out and the log file.
- supermerge - the script I'm looking for
- my_log_scanner a program that scans for error messages (I've already got that)
Note: The log files can rotate: messages, messages.1, messages.2 etc. So it is not possible to just tail the file, since it can be renamed.
tail -Fwill work with renamed files. – Dennis Williamson Sep 6 '10 at 16:45