How to add to pipes?

So my question is, can I somehow send the data to my program and then send the same data and its result to another program without creating a temporary file (in my case ouputdata.txt). It is preferable to use linux / bash lines.

I am currently doing the following:

cat inputdata.txt | ./MyProg> outputdata.txt

cat inputdata.txt outputdata.txt | ./MyProg2

+7
bash pipe
source share
2 answers

Option 1 is to correct MyProg to write the combined output from the input and its own output. Then you can do it.

 ./MyProg <inputdata.txt | ./MyProg2 

Choice 2 - If you cannot fix MyProg to record both input and output, you need to combine.

 ./MyProg <inputdata.txt | cat inputdata.txt - | ./MyProg2 
+11
source share

Here is another way that you can expand to combine the output of two programs:

 ( Prog1; Prog2; Prog3; ... ) | ProgN 

This at least works in Bash.

+21
source share

All Articles