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
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
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