I'm verifying matches of a file via SSH to a host ubunty system, and the if statement is not correctly processing the result.
export FILENAME=test.txt
export NUM=$(ssh -t ubuntu@192.168.XXX.XXX "ls ~/Documents/ | grep '$FILENAME' | wc -l")
echo "Received value: $NUM"
if [ $NUM == 0 ]; then
    echo "If processed as: 0"
else
    echo "If processed as: 1"
fi
So if $FILENAME exists, I get the following output
Connection to 192.168.XXX.XXX closed.
Received value: 1
If processed as: 1
And if not, I get the following one
Connection to 192.168.XXX.XXX closed.
Received value: 0
If processed as: 1
Why may this be happening? Am I getting a wrong formatted value? If I force before the if statement NUM=0 or NUM=1 it gets correctly processed.
 
    