Compare output of program to correct program using bash script, without using text files

Posted by Doug on Stack Overflow See other posts from Stack Overflow or by Doug
Published on 2011-01-08T02:25:06Z Indexed on 2011/01/08 2:53 UTC
Read the original article Hit count: 257

Filed under:
|

I've been trying to compare the output of a program to known correct output by using a bash script without piping the output of the program to a file and then using diff on the output file and a correct output file.

I've tried setting the variables to the output and correct output and I believe it's been successful but I can't get the string comparison to work correctly. I may be wrong about the variable setting so it could be that.

What I've been writing:

TEST=`./convert testdata.txt < somesampledata.txt`
CORRECT="some correct output"
if [ "$TEST"!="$CORRECT" ];
then
  echo "failed"
fi

© Stack Overflow or respective owner

Related posts about bash

Related posts about scripting