I am trying to write a Shell script to compile a c program and check if it prints "Hello World!" to stdout. This is what I have now. The second argument check in the diff is a file with only "Hello World!" in it.
#!/bin/sh
gcc -Wall hello.c -o hello
./hello > outfile
if diff outfile check >/dev/null ; then
echo Same
else
echo Different
fi
My Ubuntu keeps showing this error after I try to run the script.
"./build.sh: 8: ./build.sh: Syntax error: "fi" unexpected (expecting "then")"
Please let me know what is wrong with my code.