How to direct the output of a process to stdout and pipe to another process in bash?
I am using bash shell in mac
I have two python programs generate.py
and sum.py
generate.py
prints integers to stdout.
when run using python3 generate.py
it generates
1
2
3
4
...
...
sum.py
just consumes the output of generate.py
and keeps the counter and once the generate.py
is done sum.py
outputs the final value.
however when I run using the following bash command
python3 generate.py >&2 | python3 sum.py
I cannot see the output of python3 sum.py
but if I do this python3 generate.py | python3 sum.py
I can see the result from sum.py
is printed to stdout but I dont see the output from generate.py
in stdout.
so what I am looking is to see the output of both generate.py
and sum.py
while piping the data between them. any idea?