“Command not found” when attempting integer equality in bash

You need to add a space after the [ and before the ] like so:

if [ "1" -eq "2" ]

However, that way is deprecated and the better method to use is:

#!/bin/bash

if ((1 == 2)) 
then
    echo "True"
else
    echo "False"
fi

Leave a Comment