How can I pipe the std-out of multiple commands to a single command? Something like:
(cat my_program/logs/log.*;tail -0f my_program/logs/log.0) | grep "filtered lines"
I want to run all the following commands on a single command-line using pipes and no redirects to a temp file (if possible). There is one small nuance that means I can't use parentheses; I want the last command to be a tail feed so I want the grep to happen after every line is received by the std-in - not wait for EOF signal.
If the commands don't have to be executed in parallel then you can use cat to unify the output into a single consecutive stream, like this:
The magic bit is the - parameter for cat; it tells cat to take stdin and add it to the list of inputs (the others, in this case, being logfiles) to be concatenated.
Try using the current shell instead of a subshell:
The semi-colon before the closing brace is required.
Okay I have a messy solution (it's a script - sadly this would be unpractical for the command line):
I have used to FIFO method suggested by @itsbruce and I've also had to use a while loop to stop the grep from ending at the EOF signal:
I have also included a trap to delete the FIFO: