I have a two versions of a program, say : normalProgram and bruteProgram.
I have an input generator for both of these : programGenerator
Now I want to do this:
- Put the output of
./programGeneratorintoinput.txt:./programGenerator > input.txt - Redirect
input.txtas the input ofnormalProgram:cat input.txt | ./normalProgram- Put the output of
./normalProgramintoop1.txt:(cat input.txt | ./normalProgram) > op1.txt
- Put the output of
- Similar thing for
./bruteProgram:(cat input.txt | ./bruteProgram) > op2.txt
- Now I want to compare
op1.txtandop2.txt:diff op1.txt op2.txt
The whole command will look like this:
./programGenerator > input.txt &&
(cat input.txt | ./normalProgram) > op1.txt &&
(cat input.txt | ./bruteProgram) > op2.txt &&
diff op1.txt op2.txt
So this is a one time command.
I want to run this until diff op1.txt op2.txt gives a non-empty response.
I tried putting diff op1.txt op2.txt as the condition for until (or while, just to check whether the conditional is correct)
But this didn't work, and I got an error that, that is not a correct conditional.
Example:
while [diff normalOp.txt bruteOp.txt]
do
echo "hello"
done
This is giving me the error:
zsh: bad pattern: [diff
(cat input.txt | ./normalProgram) > op1.txtcan be simplified to./normalProgram < input.txt > op1.txt(which is also more efficient).