I would like to know if there is a shell in which operations such as 2| (redirect standard error of one process to the standard input of another one) exist?
I know it is possible to do it in bash with things like:
(process 2>&1) | other_process
but I find it a bit intricate when dealing with several processes.
Ideally having a 3| rather than a 2| would be perfect (my ultimate goal is to pipe the output of process to tee to create two copies of it, for instance on stdout and on the descriptor number 3, so that two processes may work on it at the same time).
That my_process_1 and my_process_2 (see below) read only from pipes (and are happy to wait for data)
You control how your program writes its output (i.e. it doesn't send stdout or stderr off somewhere else
Steps:
Create two pipes:
mknod STDOUT.pipe p
mknod STDERR.pipe p
Create two processes to read from these pipes, in the background
cat STDOUT.pipe | ./my_process_1 &
cat STDERR.pipe | ./my_process_2 &
In your program, or from a separate scripts direct STDOUT and STDERR to the new pipes
exec 1> STDOUT.pipe
exec 2> STDERR.pipe
your program call (or script) goes here
Thanks for the answers. I suspected that such a thing as 2| did not exist in any shell, but I thought this was the place to ask to be sure of it!
The idea of creating the pipes myself is pretty interesting. I don't acutally need to create a pipe for stdout since the regular pipe does that.
I tested the idea for counting the number of lines of a gzipped file and print the last lines by using one gunzip and piping the output to tee and two other processes: