edit: thank you I think that syntax wise the script is now running ok.
My script takes 4 parameters:
I want to redirect the input file into the program (in c) and then redirect the output into the log file. then check differences with the desired given output file (parameter 4). what is the most elegant way to do this?
I tried the following code which didn't work-
#!/bin/bash
$2.c < $3 > $1
var = `diff $1 $4`
if [[ var=="" ]]
then echo "Out files match"
exit 0
fi
echo "Out files mismatch"
exit 1
I have another script which compiles the.c file beforehand
#!/bin/bash
gcc -Wall -o $2 $2.c &> $1
var=`grep -e warnings -e errors $1`
if [[ $var == "" ]]
then echo "Compile succeeded"
exit 0
fi
echo "Compile failed"
exit 1
#!/bin/bash
var=`diff $1 $4`
if [[ $var == "" ]];then
echo "Out files match"
exit 0
else
echo "Out files mismatch"
echo " < : Actual output "
echo " > : Excepted output "
diff $1 $4 | grep -v "^---" | grep -v "^[0-9c0-9]"
exit 1
fi
Try above code to difference between output log and actual output
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.