0

If I have a program, its input and the desired output, how do I automate the comparison of what I want the program to give me and what it actually gives me? For example:

a=${./program < inputfile}
diff ${a} outputfile
Braiam
  • 35,991
Tom Tao
  • 13

1 Answers1

1

diff takes filenames as arguments -- you passed the data from the stdout of the command, instead. If you're using bash, zsh, or another similar shell you can use process substition:

diff <(./program < inputfile) outputfile

Or, POSIXly (you can also use a named pipe, but it's probably overkill):

./program < inputfile > /tmp/program-out
diff /tmp/program-out outputfile
rm /tmp/program-out
Chris Down
  • 125,559
  • 25
  • 270
  • 266