Let's say I have an executable called myProgram that reads from an input file and writes to an output file. A command line for this program looks like this:
./myProgram -o outputfile inputfile
The argument to the -o
option specifies an output file name; if no such file exists then the program will create it.
What I was wondering is whether I can execute myProgram multiple times, piping the output of the one instance to the input of the next. For example,
./myProgram inputfile | ./myProgram -o outputfile
Is it possible to achieve this and if so, what would I have to implement? exec calls and forking? just simple read and write calls?