I have the following piece of code which checks the contents of two files against some values in order to return a result.
if [[ "$(/bin/cat ${TMP_FILE})" != "" ]]
then
if [[ $(cat ${TMP_FILE}) -gt ${TEST1} ]]
then
res=503
sec=101
elif [[ $(cat ${TMP_FILE2}) -gt ${TEST2} ]]
then
res=503
sec=102
else
res=200
sec=103
fi
else
res=503
sec=999
fi
Basically if $TMP_FILE is blank it jumps straight to the end sec=999.
But I am also getting a result whereby if $TMP_FILE2 is blank, it also jumps to the end. How is this, as I would have expected it to fail in the second or third section (sec=102 or sec=103).
-gtoperator is used to compare integer values, and you are dumping the content of the files on the left of the operator; this will probably fail. What are the values of${TEST1}and${TEST2}? And what are the contents of the files? – cesarv Oct 19 '17 at 15:15